diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch) | |
tree | d3bb9f5d25a2dc09ca81adecf39621d871534297 /kmplot | |
download | tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmplot')
148 files changed, 18879 insertions, 0 deletions
diff --git a/kmplot/COPYING b/kmplot/COPYING new file mode 100644 index 00000000..c13faf0d --- /dev/null +++ b/kmplot/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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. + + <signature of Ty Coon>, 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. diff --git a/kmplot/KmPlot.kdevelop b/kmplot/KmPlot.kdevelop new file mode 100644 index 00000000..c430df75 --- /dev/null +++ b/kmplot/KmPlot.kdevelop @@ -0,0 +1,156 @@ +<?xml version = '1.0'?> +<kdevelop> + <general> + <author>Klaus-Dieter Moeller</author> + <email>kd.moeller@t-online.de</email> + <version>$VERSION$</version> + <projectmanagement>KDevCustomProject</projectmanagement> + <primarylanguage>C</primarylanguage> + <ignoreparts/> + <projectdirectory>.</projectdirectory> + <absoluteprojectpath>false</absoluteprojectpath> + <description/> + <secondaryLanguages> + <language>C++</language> + </secondaryLanguages> + </general> + <kdevcustomproject> + <run> + <mainprogram>kmplot/kmplot</mainprogram> + <directoryradio>executable</directoryradio> + <customdirectory>/</customdirectory> + <programargs/> + <terminal>false</terminal> + <autocompile>true</autocompile> + <envvars/> + </run> + <build> + <buildtool>make</buildtool> + <builddir/> + </build> + <make> + <abortonerror>false</abortonerror> + <numberofjobs>1</numberofjobs> + <dontact>false</dontact> + <makebin/> + <selectedenvironment>default</selectedenvironment> + <environments> + <default/> + </environments> + <makeoptions/> + </make> + </kdevcustomproject> + <kdevdebugger> + <general> + <dbgshell/> + <programargs/> + <gdbpath/> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> + <breakonloadinglibs>true</breakonloadinglibs> + <separatetty>false</separatetty> + <floatingtoolbar>false</floatingtoolbar> + </general> + <display> + <staticmembers>false</staticmembers> + <demanglenames>true</demanglenames> + <outputradix>10</outputradix> + </display> + </kdevdebugger> + <kdevdoctreeview> + <ignoretocs> + <toc>ada</toc> + <toc>ada_bugs_gcc</toc> + <toc>bash</toc> + <toc>bash_bugs</toc> + <toc>clanlib</toc> + <toc>fortran_bugs_gcc</toc> + <toc>gnome1</toc> + <toc>gnustep</toc> + <toc>gtk</toc> + <toc>gtk_bugs</toc> + <toc>haskell</toc> + <toc>haskell_bugs_ghc</toc> + <toc>java_bugs_gcc</toc> + <toc>java_bugs_sun</toc> + <toc>kde2book</toc> + <toc>libstdc++</toc> + <toc>opengl</toc> + <toc>pascal_bugs_fp</toc> + <toc>php</toc> + <toc>php_bugs</toc> + <toc>perl</toc> + <toc>perl_bugs</toc> + <toc>python</toc> + <toc>python_bugs</toc> + <toc>qt-kdev3</toc> + <toc>ruby</toc> + <toc>ruby_bugs</toc> + <toc>sdl</toc> + <toc>stl</toc> + <toc>sw</toc> + <toc>w3c-dom-level2-html</toc> + <toc>w3c-svg</toc> + <toc>w3c-uaag10</toc> + <toc>wxwindows_bugs</toc> + </ignoretocs> + <ignoreqt_xml> + <toc>Guide to the Qt Translation Tools</toc> + <toc>Qt Assistant Manual</toc> + <toc>Qt Designer Manual</toc> + <toc>Qt Reference Documentation</toc> + <toc>qmake User Guide</toc> + </ignoreqt_xml> + <ignoredoxygen> + <toc>KDE Libraries (Doxygen)</toc> + </ignoredoxygen> + <projectdoc> + <userdocDir>html/</userdocDir> + <apidocDir>html/</apidocDir> + </projectdoc> + <ignorekdocs/> + <ignoredevhelp/> + </kdevdoctreeview> + <kdevfilecreate> + <filetypes/> + <useglobaltypes> + <type ext="c" /> + <type ext="h" /> + </useglobaltypes> + </kdevfilecreate> + <kdevcppsupport> + <references> + <pcs>Qt</pcs> + <pcs>KDElibs</pcs> + </references> + <codecompletion> + <includeGlobalFunctions>true</includeGlobalFunctions> + <includeTypes>true</includeTypes> + <includeEnums>true</includeEnums> + <includeTypedefs>false</includeTypedefs> + <automaticCodeCompletion>true</automaticCodeCompletion> + <automaticArgumentsHint>true</automaticArgumentsHint> + <automaticHeaderCompletion>true</automaticHeaderCompletion> + <codeCompletionDelay>250</codeCompletionDelay> + <argumentsHintDelay>400</argumentsHintDelay> + <headerCompletionDelay>250</headerCompletionDelay> + </codecompletion> + </kdevcppsupport> + <kdevfileview> + <groups> + <hidenonprojectfiles>false</hidenonprojectfiles> + <hidenonlocation>false</hidenonlocation> + </groups> + <tree> + <hidepatterns>*.o,*.lo,CVS,*.moc,*~</hidepatterns> + <hidenonprojectfiles>false</hidenonprojectfiles> + </tree> + </kdevfileview> + <cppsupportpart> + <filetemplates> + <interfacesuffix>.h</interfacesuffix> + <implementationsuffix>.cpp</implementationsuffix> + </filetemplates> + </cppsupportpart> +</kdevelop> diff --git a/kmplot/KmPlot.kdevelop.filelist b/kmplot/KmPlot.kdevelop.filelist new file mode 100644 index 00000000..7e79f898 --- /dev/null +++ b/kmplot/KmPlot.kdevelop.filelist @@ -0,0 +1,89 @@ +# KDevelop Custom Project File List +KmPlot.kdevelop +Makefile.am +TODO +pics/coords.png +pics/kfkt.png +pics/ksys1.png +pics/ksys2.png +pics/ksys3.png +pics/Makefile.am +pics/scaling.png +kmplot/AttrDlg.cpp +kmplot/AttrDlg.h +kmplot/AttrDlgData.ui +kmplot/BezWnd.cpp +kmplot/BezWnd.h +kmplot/BezWndData.ui +kmplot/diagr.cpp +kmplot/diagr.h +kmplot/FktDlg.cpp +kmplot/FktDlg.h +kmplot/FktDlgData.ui +kmplot/kmplot.desktop +kmplot/kmplot.kcfg +kmplot/kmplotui.rc +kmplot/KoordDlg.cpp +kmplot/KoordDlg.h +kmplot/KoordDlgData.ui +kmplot/KOptDlg.cpp +kmplot/KOptDlg.h +kmplot/KOptDlgData.ui +kmplot/kprinterdlg.cpp +kmplot/kprinterdlg.h +kmplot/ksettingsdlg.cpp +kmplot/ksettingsdlg.h +kmplot/main.cpp +kmplot/main.h +kmplot/MainDlg.cpp +kmplot/MainDlg.h +kmplot/Makefile.am +kmplot/misc.cpp +kmplot/misc.h +kmplot/parser.cpp +kmplot/parser.h +kmplot/RstDlg.cpp +kmplot/RstDlg.h +kmplot/RstDlgData.ui +kmplot/settings.kcfgc +kmplot/settingspagecolor.ui +kmplot/settingspagecoords.ui +kmplot/settingspagefonts.ui +kmplot/settingspagescaling.ui +kmplot/SkalDlg.cpp +kmplot/SkalDlg.h +kmplot/SkalDlgData.ui +kmplot/SwDlg.cpp +kmplot/SwDlg.h +kmplot/SwDlgData.ui +kmplot/View.cpp +kmplot/View.h +kmplot/x-kmplot.desktop +kmplot/xparser.cpp +kmplot/xparser.h +icons/cr128-app-kmplot.png +icons/cr16-app-kmplot.png +icons/cr32-app-kmplot.png +icons/cr48-app-kmplot.png +icons/Makefile.am +KmPlot.kdevelop.filelist +/keditfunction.h +/keditfunction.cpp +kmplot/qeditfunction.ui +/keditfunction2.h +/keditfunction2.cpp +/kfunctionedit.h +/kfunctionedit.cpp +keditfunction.h +keditfunction.cpp.c +kmplot/keditfunction.h +kmplot/keditfunction.cpp +/qfunctionlist.h +/qfunctionlist.cpp +kmplot/settingspageprecision.ui +kmplot/keditparametric.cpp +kmplot/keditparametric.h +kmplot/keditpolar.cpp +kmplot/keditpolar.h +kmplot/qeditparametric.ui +kmplot/qeditpolar.ui diff --git a/kmplot/Makefile.am b/kmplot/Makefile.am new file mode 100644 index 00000000..e8002ec3 --- /dev/null +++ b/kmplot/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = kmplot icons + +EXTRA_DIST = KmPlot.kdevelop KmPlot.kdevelop.filelist TODO + +AUTOMAKE_OPTIONS = foreign + +include ../admin/Doxyfile.am diff --git a/kmplot/TODO b/kmplot/TODO new file mode 100644 index 00000000..1a9acc22 --- /dev/null +++ b/kmplot/TODO @@ -0,0 +1,80 @@ +Last modified: 2005-03-24 + +TODO +========================= +* Find bugs +* More functions? +* In tool menu: + * find "nollstllen" ( en: where the function's value is 0) + * get slope for a x-point + * Value table +* Fix the unpolished lines? +* #52887, need to calculate with complex numbers. +* Popupmenu and tracemode for parametric- and polar functions +* Draw tangents in trace mode (pipesmoker) +* Printing (pipesmoker) + - different paper sizes +* Use a better(faster!) algorithm for drawing integrals numeric. It's not urgent anymore since the implemention of Euler's method is better now. +* An export dialog where you can set the size and enable/disable monocrome. +* More printing options. + +IN PROGRESS +========================= +* Import parameter values from different file format(.csv, KSpread, OpenOffice) via Koffice (see kde-edu/kig) + +DONE +========================= + +* Function edit Dialog + - Apply button for edit of more than one function in one go +* Printing + - possibility for omitting the Header +* Porting File save format to xml +* Bug #80739 +* A constant editor which can imports/export constants from KCalc +* Progressbar + stopbutton when drawing anti-derivates. +* No re-drawing then the user don't make any changes in the function editor dialog +* handle with comma-characters +* Replace the comma-seperated KLineEdit with a new dialog +* Parse the new dialog's values. +* don't freeze at rf(x)=ln(x) +* Set background color +* In tool menu: + * maximumvalue + * minimumvalue + * get the y-value from a x-value +* Default color for derivatives and anti-derivatives. +* Range check when adding plot functions. +* Don't calculate stepWidth if nothing is changed. +* Import parameter values from .txt-files +* Navigating in trace mode with the keyboard +* Trace mode with derivatives +* Fix totalsteps in progressbar +* In tool menu: + * area under a graph +* Printable area-under-graphs +* Draw functions with parameters in tool-menu +* Version check +* Load old Kmplot files without crash +* Popup tool menu when right clicking on a graph +* Ask the user (yes|no) when he or she saves an old kmplot file +* Don't save a file if it isn't necessary +* Fix scaling +* Change icon when zooming +* Ability to print background color +* Four modes for zooming. +* Basic popup menu for single parametric points. +* Configure Dialog for global Settings / save as default Checkboxes (Started) +* Replace QFile with KIO in KmplotIO. +* Ability to export the parameter values. +* Support for more than 10 functions. +* Support for more than 10 parameter values for a function. +* Improved drawing of integrals (faster!) +* KPart +* Ability to set font size when drawing labels. +* Automatic choose a new function if the user want to define a function name that already exists. +* Move and copy functions to other instances of KmPlot. +* DCOP +* Make it possible to set a min OR max range value for functions. +* Checkbox in the function list to show/hide functions. +* Ability to set min and max values for the sliders.
\ No newline at end of file diff --git a/kmplot/icons/Makefile.am b/kmplot/icons/Makefile.am new file mode 100644 index 00000000..6e22aa71 --- /dev/null +++ b/kmplot/icons/Makefile.am @@ -0,0 +1,3 @@ + +SUBDIRS = actions +KDE_ICON=AUTO
\ No newline at end of file diff --git a/kmplot/icons/actions/Makefile.am b/kmplot/icons/actions/Makefile.am new file mode 100644 index 00000000..3dfaa660 --- /dev/null +++ b/kmplot/icons/actions/Makefile.am @@ -0,0 +1,2 @@ +kmploticonsdir = $(kde_datadir)/kmplot/icons +kmploticons_ICON = AUTO diff --git a/kmplot/icons/actions/cr16-action-editplots.png b/kmplot/icons/actions/cr16-action-editplots.png Binary files differnew file mode 100644 index 00000000..fd0b4b6e --- /dev/null +++ b/kmplot/icons/actions/cr16-action-editplots.png diff --git a/kmplot/icons/actions/cr16-action-functionhelp.png b/kmplot/icons/actions/cr16-action-functionhelp.png Binary files differnew file mode 100644 index 00000000..9f4ccc65 --- /dev/null +++ b/kmplot/icons/actions/cr16-action-functionhelp.png diff --git a/kmplot/icons/actions/cr16-action-ksys1.png b/kmplot/icons/actions/cr16-action-ksys1.png Binary files differnew file mode 100644 index 00000000..5d4f623b --- /dev/null +++ b/kmplot/icons/actions/cr16-action-ksys1.png diff --git a/kmplot/icons/actions/cr16-action-ksys2.png b/kmplot/icons/actions/cr16-action-ksys2.png Binary files differnew file mode 100644 index 00000000..2c9d8a51 --- /dev/null +++ b/kmplot/icons/actions/cr16-action-ksys2.png diff --git a/kmplot/icons/actions/cr16-action-ksys3.png b/kmplot/icons/actions/cr16-action-ksys3.png Binary files differnew file mode 100644 index 00000000..62710043 --- /dev/null +++ b/kmplot/icons/actions/cr16-action-ksys3.png diff --git a/kmplot/icons/actions/cr16-action-maximum.png b/kmplot/icons/actions/cr16-action-maximum.png Binary files differnew file mode 100644 index 00000000..12cb9d5f --- /dev/null +++ b/kmplot/icons/actions/cr16-action-maximum.png diff --git a/kmplot/icons/actions/cr16-action-minimum.png b/kmplot/icons/actions/cr16-action-minimum.png Binary files differnew file mode 100644 index 00000000..c7e52031 --- /dev/null +++ b/kmplot/icons/actions/cr16-action-minimum.png diff --git a/kmplot/icons/actions/cr16-action-newfunction.png b/kmplot/icons/actions/cr16-action-newfunction.png Binary files differnew file mode 100644 index 00000000..5d9182c4 --- /dev/null +++ b/kmplot/icons/actions/cr16-action-newfunction.png diff --git a/kmplot/icons/actions/cr16-action-newparametric.png b/kmplot/icons/actions/cr16-action-newparametric.png Binary files differnew file mode 100644 index 00000000..61b38232 --- /dev/null +++ b/kmplot/icons/actions/cr16-action-newparametric.png diff --git a/kmplot/icons/actions/cr16-action-newpolar.png b/kmplot/icons/actions/cr16-action-newpolar.png Binary files differnew file mode 100644 index 00000000..aae5f5f8 --- /dev/null +++ b/kmplot/icons/actions/cr16-action-newpolar.png diff --git a/kmplot/icons/actions/cr22-action-editplots.png b/kmplot/icons/actions/cr22-action-editplots.png Binary files differnew file mode 100644 index 00000000..78e0fe7a --- /dev/null +++ b/kmplot/icons/actions/cr22-action-editplots.png diff --git a/kmplot/icons/actions/cr22-action-functionhelp.png b/kmplot/icons/actions/cr22-action-functionhelp.png Binary files differnew file mode 100644 index 00000000..a5264214 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-functionhelp.png diff --git a/kmplot/icons/actions/cr22-action-ksys1.png b/kmplot/icons/actions/cr22-action-ksys1.png Binary files differnew file mode 100644 index 00000000..7cbb1cc2 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-ksys1.png diff --git a/kmplot/icons/actions/cr22-action-ksys2.png b/kmplot/icons/actions/cr22-action-ksys2.png Binary files differnew file mode 100644 index 00000000..bc095525 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-ksys2.png diff --git a/kmplot/icons/actions/cr22-action-ksys3.png b/kmplot/icons/actions/cr22-action-ksys3.png Binary files differnew file mode 100644 index 00000000..f40600ec --- /dev/null +++ b/kmplot/icons/actions/cr22-action-ksys3.png diff --git a/kmplot/icons/actions/cr22-action-maximum.png b/kmplot/icons/actions/cr22-action-maximum.png Binary files differnew file mode 100644 index 00000000..80103583 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-maximum.png diff --git a/kmplot/icons/actions/cr22-action-minimum.png b/kmplot/icons/actions/cr22-action-minimum.png Binary files differnew file mode 100644 index 00000000..fa4eb320 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-minimum.png diff --git a/kmplot/icons/actions/cr22-action-newfunction.png b/kmplot/icons/actions/cr22-action-newfunction.png Binary files differnew file mode 100644 index 00000000..86281a78 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-newfunction.png diff --git a/kmplot/icons/actions/cr22-action-newparametric.png b/kmplot/icons/actions/cr22-action-newparametric.png Binary files differnew file mode 100644 index 00000000..b0865220 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-newparametric.png diff --git a/kmplot/icons/actions/cr22-action-newpolar.png b/kmplot/icons/actions/cr22-action-newpolar.png Binary files differnew file mode 100644 index 00000000..dec65b92 --- /dev/null +++ b/kmplot/icons/actions/cr22-action-newpolar.png diff --git a/kmplot/icons/actions/cr32-action-coords.png b/kmplot/icons/actions/cr32-action-coords.png Binary files differnew file mode 100644 index 00000000..5f94ab16 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-coords.png diff --git a/kmplot/icons/actions/cr32-action-deriv_func.png b/kmplot/icons/actions/cr32-action-deriv_func.png Binary files differnew file mode 100644 index 00000000..1d1fd7ea --- /dev/null +++ b/kmplot/icons/actions/cr32-action-deriv_func.png diff --git a/kmplot/icons/actions/cr32-action-editconstants.png b/kmplot/icons/actions/cr32-action-editconstants.png Binary files differnew file mode 100644 index 00000000..192cbad4 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-editconstants.png diff --git a/kmplot/icons/actions/cr32-action-editplots.png b/kmplot/icons/actions/cr32-action-editplots.png Binary files differnew file mode 100644 index 00000000..ba942cf6 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-editplots.png diff --git a/kmplot/icons/actions/cr32-action-func.png b/kmplot/icons/actions/cr32-action-func.png Binary files differnew file mode 100644 index 00000000..7e654827 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-func.png diff --git a/kmplot/icons/actions/cr32-action-functionhelp.png b/kmplot/icons/actions/cr32-action-functionhelp.png Binary files differnew file mode 100644 index 00000000..64521ef2 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-functionhelp.png diff --git a/kmplot/icons/actions/cr32-action-integral_func.png b/kmplot/icons/actions/cr32-action-integral_func.png Binary files differnew file mode 100644 index 00000000..e4f4161f --- /dev/null +++ b/kmplot/icons/actions/cr32-action-integral_func.png diff --git a/kmplot/icons/actions/cr32-action-ksys1.png b/kmplot/icons/actions/cr32-action-ksys1.png Binary files differnew file mode 100644 index 00000000..a5a22e9b --- /dev/null +++ b/kmplot/icons/actions/cr32-action-ksys1.png diff --git a/kmplot/icons/actions/cr32-action-ksys2.png b/kmplot/icons/actions/cr32-action-ksys2.png Binary files differnew file mode 100644 index 00000000..2fbf7f00 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-ksys2.png diff --git a/kmplot/icons/actions/cr32-action-ksys3.png b/kmplot/icons/actions/cr32-action-ksys3.png Binary files differnew file mode 100644 index 00000000..ef0fd0fa --- /dev/null +++ b/kmplot/icons/actions/cr32-action-ksys3.png diff --git a/kmplot/icons/actions/cr32-action-lessen.png b/kmplot/icons/actions/cr32-action-lessen.png Binary files differnew file mode 100644 index 00000000..59233667 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-lessen.png diff --git a/kmplot/icons/actions/cr32-action-magnify.png b/kmplot/icons/actions/cr32-action-magnify.png Binary files differnew file mode 100644 index 00000000..28b865f7 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-magnify.png diff --git a/kmplot/icons/actions/cr32-action-maximum.png b/kmplot/icons/actions/cr32-action-maximum.png Binary files differnew file mode 100644 index 00000000..2bc6eb6d --- /dev/null +++ b/kmplot/icons/actions/cr32-action-maximum.png diff --git a/kmplot/icons/actions/cr32-action-minimum.png b/kmplot/icons/actions/cr32-action-minimum.png Binary files differnew file mode 100644 index 00000000..df8db60e --- /dev/null +++ b/kmplot/icons/actions/cr32-action-minimum.png diff --git a/kmplot/icons/actions/cr32-action-newfunction.png b/kmplot/icons/actions/cr32-action-newfunction.png Binary files differnew file mode 100644 index 00000000..32d22fb6 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-newfunction.png diff --git a/kmplot/icons/actions/cr32-action-newparametric.png b/kmplot/icons/actions/cr32-action-newparametric.png Binary files differnew file mode 100644 index 00000000..a32a1969 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-newparametric.png diff --git a/kmplot/icons/actions/cr32-action-newpolar.png b/kmplot/icons/actions/cr32-action-newpolar.png Binary files differnew file mode 100644 index 00000000..b307afa1 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-newpolar.png diff --git a/kmplot/icons/actions/cr32-action-scaling.png b/kmplot/icons/actions/cr32-action-scaling.png Binary files differnew file mode 100644 index 00000000..b9f4af86 --- /dev/null +++ b/kmplot/icons/actions/cr32-action-scaling.png diff --git a/kmplot/icons/actions/cr48-action-editplots.png b/kmplot/icons/actions/cr48-action-editplots.png Binary files differnew file mode 100644 index 00000000..52511214 --- /dev/null +++ b/kmplot/icons/actions/cr48-action-editplots.png diff --git a/kmplot/icons/actions/cr48-action-functionhelp.png b/kmplot/icons/actions/cr48-action-functionhelp.png Binary files differnew file mode 100644 index 00000000..58ff782c --- /dev/null +++ b/kmplot/icons/actions/cr48-action-functionhelp.png diff --git a/kmplot/icons/actions/cr48-action-integral_func.png b/kmplot/icons/actions/cr48-action-integral_func.png Binary files differnew file mode 100644 index 00000000..e7ef66ef --- /dev/null +++ b/kmplot/icons/actions/cr48-action-integral_func.png diff --git a/kmplot/icons/actions/cr48-action-ksys1.png b/kmplot/icons/actions/cr48-action-ksys1.png Binary files differnew file mode 100644 index 00000000..6a1ed976 --- /dev/null +++ b/kmplot/icons/actions/cr48-action-ksys1.png diff --git a/kmplot/icons/actions/cr48-action-ksys2.png b/kmplot/icons/actions/cr48-action-ksys2.png Binary files differnew file mode 100644 index 00000000..69766eee --- /dev/null +++ b/kmplot/icons/actions/cr48-action-ksys2.png diff --git a/kmplot/icons/actions/cr48-action-ksys3.png b/kmplot/icons/actions/cr48-action-ksys3.png Binary files differnew file mode 100644 index 00000000..5facf747 --- /dev/null +++ b/kmplot/icons/actions/cr48-action-ksys3.png diff --git a/kmplot/icons/actions/cr48-action-maximum.png b/kmplot/icons/actions/cr48-action-maximum.png Binary files differnew file mode 100644 index 00000000..2fc2e9a0 --- /dev/null +++ b/kmplot/icons/actions/cr48-action-maximum.png diff --git a/kmplot/icons/actions/cr48-action-minimum.png b/kmplot/icons/actions/cr48-action-minimum.png Binary files differnew file mode 100644 index 00000000..da24a3a9 --- /dev/null +++ b/kmplot/icons/actions/cr48-action-minimum.png diff --git a/kmplot/icons/actions/cr48-action-newfunction.png b/kmplot/icons/actions/cr48-action-newfunction.png Binary files differnew file mode 100644 index 00000000..249b62b1 --- /dev/null +++ b/kmplot/icons/actions/cr48-action-newfunction.png diff --git a/kmplot/icons/actions/cr48-action-newparametric.png b/kmplot/icons/actions/cr48-action-newparametric.png Binary files differnew file mode 100644 index 00000000..74843d4c --- /dev/null +++ b/kmplot/icons/actions/cr48-action-newparametric.png diff --git a/kmplot/icons/actions/cr48-action-newpolar.png b/kmplot/icons/actions/cr48-action-newpolar.png Binary files differnew file mode 100644 index 00000000..f3697116 --- /dev/null +++ b/kmplot/icons/actions/cr48-action-newpolar.png diff --git a/kmplot/icons/actions/cr64-action-maximum.png b/kmplot/icons/actions/cr64-action-maximum.png Binary files differnew file mode 100644 index 00000000..0be1c598 --- /dev/null +++ b/kmplot/icons/actions/cr64-action-maximum.png diff --git a/kmplot/icons/actions/cr64-action-minimum.png b/kmplot/icons/actions/cr64-action-minimum.png Binary files differnew file mode 100644 index 00000000..acfb195f --- /dev/null +++ b/kmplot/icons/actions/cr64-action-minimum.png diff --git a/kmplot/icons/actions/crsc-action-deriv_func.svgz b/kmplot/icons/actions/crsc-action-deriv_func.svgz Binary files differnew file mode 100644 index 00000000..6c95f644 --- /dev/null +++ b/kmplot/icons/actions/crsc-action-deriv_func.svgz diff --git a/kmplot/icons/actions/crsc-action-editconstants.svgz b/kmplot/icons/actions/crsc-action-editconstants.svgz Binary files differnew file mode 100644 index 00000000..fcc1803f --- /dev/null +++ b/kmplot/icons/actions/crsc-action-editconstants.svgz diff --git a/kmplot/icons/actions/crsc-action-editplots.svgz b/kmplot/icons/actions/crsc-action-editplots.svgz Binary files differnew file mode 100644 index 00000000..7d515cca --- /dev/null +++ b/kmplot/icons/actions/crsc-action-editplots.svgz diff --git a/kmplot/icons/actions/crsc-action-functionhelp.svgz b/kmplot/icons/actions/crsc-action-functionhelp.svgz Binary files differnew file mode 100644 index 00000000..ee62a812 --- /dev/null +++ b/kmplot/icons/actions/crsc-action-functionhelp.svgz diff --git a/kmplot/icons/actions/crsc-action-integral_func.svgz b/kmplot/icons/actions/crsc-action-integral_func.svgz Binary files differnew file mode 100644 index 00000000..7a79a7ae --- /dev/null +++ b/kmplot/icons/actions/crsc-action-integral_func.svgz diff --git a/kmplot/icons/actions/crsc-action-ksys1.svgz b/kmplot/icons/actions/crsc-action-ksys1.svgz Binary files differnew file mode 100644 index 00000000..b49765c8 --- /dev/null +++ b/kmplot/icons/actions/crsc-action-ksys1.svgz diff --git a/kmplot/icons/actions/crsc-action-ksys2.svgz b/kmplot/icons/actions/crsc-action-ksys2.svgz Binary files differnew file mode 100644 index 00000000..79ac96a9 --- /dev/null +++ b/kmplot/icons/actions/crsc-action-ksys2.svgz diff --git a/kmplot/icons/actions/crsc-action-ksys3.svgz b/kmplot/icons/actions/crsc-action-ksys3.svgz Binary files differnew file mode 100644 index 00000000..907f890e --- /dev/null +++ b/kmplot/icons/actions/crsc-action-ksys3.svgz diff --git a/kmplot/icons/actions/crsc-action-maximum.svgz b/kmplot/icons/actions/crsc-action-maximum.svgz Binary files differnew file mode 100644 index 00000000..e4bb1ba3 --- /dev/null +++ b/kmplot/icons/actions/crsc-action-maximum.svgz diff --git a/kmplot/icons/actions/crsc-action-minimum.svgz b/kmplot/icons/actions/crsc-action-minimum.svgz Binary files differnew file mode 100644 index 00000000..8d2c42f6 --- /dev/null +++ b/kmplot/icons/actions/crsc-action-minimum.svgz diff --git a/kmplot/icons/actions/crsc-action-newfunction.svgz b/kmplot/icons/actions/crsc-action-newfunction.svgz Binary files differnew file mode 100644 index 00000000..ead8e42e --- /dev/null +++ b/kmplot/icons/actions/crsc-action-newfunction.svgz diff --git a/kmplot/icons/actions/crsc-action-newparametric.svgz b/kmplot/icons/actions/crsc-action-newparametric.svgz Binary files differnew file mode 100644 index 00000000..9ab6e61a --- /dev/null +++ b/kmplot/icons/actions/crsc-action-newparametric.svgz diff --git a/kmplot/icons/actions/crsc-action-newpolar.svgz b/kmplot/icons/actions/crsc-action-newpolar.svgz Binary files differnew file mode 100644 index 00000000..816f213d --- /dev/null +++ b/kmplot/icons/actions/crsc-action-newpolar.svgz diff --git a/kmplot/icons/hi128-app-kmplot.png b/kmplot/icons/hi128-app-kmplot.png Binary files differnew file mode 100644 index 00000000..0acdedec --- /dev/null +++ b/kmplot/icons/hi128-app-kmplot.png diff --git a/kmplot/icons/hi16-app-kmplot.png b/kmplot/icons/hi16-app-kmplot.png Binary files differnew file mode 100644 index 00000000..56ebd2e7 --- /dev/null +++ b/kmplot/icons/hi16-app-kmplot.png diff --git a/kmplot/icons/hi22-app-kmplot.png b/kmplot/icons/hi22-app-kmplot.png Binary files differnew file mode 100644 index 00000000..5f9a283b --- /dev/null +++ b/kmplot/icons/hi22-app-kmplot.png diff --git a/kmplot/icons/hi32-app-kmplot.png b/kmplot/icons/hi32-app-kmplot.png Binary files differnew file mode 100644 index 00000000..98fa9c75 --- /dev/null +++ b/kmplot/icons/hi32-app-kmplot.png diff --git a/kmplot/icons/hi48-app-kmplot.png b/kmplot/icons/hi48-app-kmplot.png Binary files differnew file mode 100644 index 00000000..0873b559 --- /dev/null +++ b/kmplot/icons/hi48-app-kmplot.png diff --git a/kmplot/icons/hi64-app-kmplot.png b/kmplot/icons/hi64-app-kmplot.png Binary files differnew file mode 100644 index 00000000..cd499844 --- /dev/null +++ b/kmplot/icons/hi64-app-kmplot.png diff --git a/kmplot/icons/hisc-app-kmplot.svgz b/kmplot/icons/hisc-app-kmplot.svgz Binary files differnew file mode 100644 index 00000000..38fc974a --- /dev/null +++ b/kmplot/icons/hisc-app-kmplot.svgz diff --git a/kmplot/kmplot/FktDlg.cpp b/kmplot/kmplot/FktDlg.cpp new file mode 100644 index 00000000..aef0b3f4 --- /dev/null +++ b/kmplot/kmplot/FktDlg.cpp @@ -0,0 +1,337 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +// Qt includes +// #include <qpushbutton.h> +// #include <qpopupmenu.h> + +// KDE includes +#include <kapplication.h> +#include <klistview.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpushbutton.h> +#include <qcstring.h> +#include <qcursor.h> +#include <qheader.h> + +// locale includes +#include "FktDlg.h" +#include "FktDlg.moc" +#include "editfunction.h" +#include "keditparametric.h" +#include "keditpolar.h" +#include "MainDlg.h" +#include "parseriface.h" +#include "xparser.h" + +#include <kdebug.h> + +FktDlg::FktDlg( QWidget* parent, View *view ) : FktDlgData( parent, "editPlots" ), m_view(view) +{ + connect( cmdCopyFunction, SIGNAL( clicked() ), this, SLOT( slotCopyFunction()) ); + connect( cmdMoveFunction, SIGNAL( clicked() ), this, SLOT( slotMoveFunction()) ); + connect( lb_fktliste, SIGNAL( doubleClicked(QListViewItem *, const QPoint &, int)), this, SLOT(lb_fktliste_doubleClicked(QListViewItem *, const QPoint &, int)) ); + connect( lb_fktliste, SIGNAL( clicked(QListViewItem *)), this, SLOT(lb_fktliste_clicked(QListViewItem *))); + connect( lb_fktliste, SIGNAL( spacePressed(QListViewItem *)), this, SLOT(lb_fktliste_spacePressed(QListViewItem *))); + + lb_fktliste->addColumn( "" ); + lb_fktliste->header()->hide(); + lb_fktliste->setResizeMode( QListView::LastColumn ); +} + +FktDlg::~FktDlg() +{ +} + +void FktDlg::slotDelete() +{ + if ( lb_fktliste->currentItem() == 0) + return; + QCheckListItem *currentItem = dynamic_cast<QCheckListItem *>(lb_fktliste->currentItem()); + if( currentItem->text()[0] == 'x' ) + { + // Delete pair of parametric function + int const id = getParamId( currentItem->text()); + if ( id == -1) + return; + if ( !m_view->parser()->delfkt(id)) + return; + } + else + { + // only one function to be deleted + if (!m_view->parser()->delfkt( getId( currentItem->text()) ) ) + return; + } + lb_fktliste->takeItem( currentItem ); + changed = true; + updateView(); + if ( lb_fktliste->childCount()==0 ) + PushButtonDel->setEnabled(false); +} + +void FktDlg::lb_fktliste_doubleClicked( QListViewItem *, const QPoint &, int ) +{ + if ( mapFromGlobal(QCursor::pos()).x() <= 40 ) + return; + slotEdit(); +} + +void FktDlg::lb_fktliste_spacePressed( QListViewItem *item) +{ + if ( !item ) + return; + QCheckListItem *currentItem = dynamic_cast<QCheckListItem *>(item); + int id; + if ( currentItem->text()[0] == 'x' ) + id = getParamId(currentItem->text()); + else + id = getId(currentItem->text()); + Ufkt *function = &m_view->parser()->ufkt[ m_view->parser()->ixValue(id) ]; + if ( id==-1 ) + return; + + function->f_mode=currentItem->isOn(); + updateView(); +} + +void FktDlg::lb_fktliste_clicked( QListViewItem * item ) +{ + if ( mapFromGlobal(QCursor::pos()).x() > 40 ) + return; + lb_fktliste_spacePressed(item); +} + + +void FktDlg::slotEdit() +{ + QCheckListItem *currentItem = dynamic_cast<QCheckListItem *>(lb_fktliste->currentItem()); + if ( currentItem == 0 ) + { + PushButtonEdit->setEnabled(false); + return; + } + int const id = getId( currentItem->text().section( ";", 0, 0) ) ; + + // find out the function type + char const prefix = m_view->parser()->ufkt[ m_view->parser()->ixValue(id) ].fstr.at(0).latin1(); + + if ( prefix == 'r') + slotEditPolar( id ); + else if ( prefix == 'x') + slotEditParametric( id, m_view->parser()->ixValue(getId( currentItem->text().section( ";", 1, 1) ))); + else + slotEditFunction( id ); +} + +int FktDlg::getId( const QString &f_str ) +{ + for( QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it != m_view->parser()->ufkt.end(); ++it) + { + if ( it->fstr == f_str ) + return it->id; + } + return -1; +} + +int FktDlg::getParamId( const QString &f_str) +{ + QString const fname = f_str.section( "(", 0, 0 ); + for( QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it != m_view->parser()->ufkt.end(); ++it) + { + if ( it->fname == fname ) + return it->id; + } + return -1; +} + +void FktDlg::updateView() +{ + m_view->drawPlot(); +} + +void FktDlg::slotHasSelection() +{ + bool const has_selection = !( lb_fktliste->currentItem() == 0 ); + PushButtonEdit->setEnabled( has_selection ); + PushButtonDel->setEnabled( has_selection ); + cmdCopyFunction->setEnabled( has_selection ); + cmdMoveFunction->setEnabled( has_selection ); +} + +void FktDlg::slotEditFunction( int id ) +{ + EditFunction* editFunction = new EditFunction( m_view->parser(), this ); + if ( id==-1 ) editFunction->setCaption(i18n( "New Function Plot" )); + else editFunction->setCaption(i18n( "Edit Function Plot" )); + editFunction->initDialog( id ); + if( editFunction->exec() == QDialog::Accepted ) + { + Ufkt *function = editFunction->functionItem(); + QCheckListItem *item; + if( id == -1 ) //a new function + item = new QCheckListItem(lb_fktliste, function->fstr, QCheckListItem::CheckBox); //a new function + else //change a function + { + item = dynamic_cast<QCheckListItem *>(lb_fktliste->currentItem()); + item->setText(0, function->fstr ); + } + item->setOn(function->f_mode); + lb_fktliste->sort(); + changed = true; + updateView(); + } +} + +void FktDlg::slotEditParametric( int x_id, int y_id) +{ + KEditParametric* editParametric = new KEditParametric( m_view->parser(), this ); + if ( x_id==-1 && y_id==-1) + editParametric->setCaption(i18n( "New Parametric Plot" )); + editParametric->initDialog( x_id, y_id ); + if( editParametric->exec() == QDialog::Accepted ) + { + Ufkt *function_y = editParametric->functionItem(); + Ufkt *function_x = &m_view->parser()->ufkt[m_view->parser()->ixValue(function_y->id - 1)]; //get the x-function + QCheckListItem *item; + if( x_id == -1 ) //a new function + { + item = new QCheckListItem(lb_fktliste, function_x->fstr+";"+function_y->fstr, QCheckListItem::CheckBox); + } + else //change a function + { + item = dynamic_cast<QCheckListItem *>(lb_fktliste->currentItem()); + item->setText(0, function_x->fstr+";"+function_y->fstr ); + } + item->setOn(function_y->f_mode); + lb_fktliste->sort(); + changed = true; + updateView(); + } +} + +void FktDlg::slotEditPolar( int id ) +{ + KEditPolar* editPolar = new KEditPolar( m_view->parser(), this ); + if ( id==-1) editPolar->setCaption(i18n( "New Polar Plot" )); + editPolar->initDialog( id ); + if( editPolar->exec() == QDialog::Accepted ) + { + Ufkt *function = editPolar->functionItem(); + QCheckListItem *item; + if( id == -1 ) // a new function + { + item = new QCheckListItem(lb_fktliste, function->fstr, QCheckListItem::CheckBox); + } + else //change a function + { + item = dynamic_cast<QCheckListItem *>(lb_fktliste->currentItem()); + item->setText(0, function->fstr ); + } + item->setOn(function->f_mode); + lb_fktliste->sort(); + changed = true; + updateView(); + } +} + +void FktDlg::slotNewFunction() +{ + slotEditFunction(); +} + +void FktDlg::slotNewParametric() +{ + slotEditParametric(); +} + +void FktDlg::slotNewPolar() +{ + slotEditPolar(); +} + +void FktDlg::getPlots() +{ + lb_fktliste->clear(); + + // adding all yet added functions + for( QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it != m_view->parser()->ufkt.end(); ++it) + { + if( it->fname.isEmpty() || it->fstr[0] == 'y' ) continue; + QCheckListItem *item; + if( it->fstr[0] == 'x' ) + { + QString y = it->fstr; + ++it; + item = new QCheckListItem( lb_fktliste, y + ";" + it->fstr, QCheckListItem::CheckBox ); + } + else + item = new QCheckListItem(lb_fktliste, it->fstr, QCheckListItem::CheckBox); + item->setOn(it->f_mode); + } + lb_fktliste->sort(); +} + +void FktDlg::slotHelp() +{ + kapp->invokeHelp( "", "kmplot" ); +} + +bool FktDlg::isChanged() +{ + return changed; +} + +void FktDlg::showEvent ( QShowEvent * ) +{ + changed = false; +} + +void FktDlg::slotCopyFunction() +{ + if ( lb_fktliste->currentItem() == 0) + { + cmdCopyFunction->setEnabled(false); + return; + } + QCheckListItem *currentItem = dynamic_cast<QCheckListItem *>(lb_fktliste->currentItem()); + QString const fstr = currentItem->text(); + m_view->parser()->sendFunction(getId(fstr)); +} + +void FktDlg::slotMoveFunction() +{ + if ( lb_fktliste->currentItem() == 0) + { + cmdCopyFunction->setEnabled(false); + return; + } + QCheckListItem *currentItem = dynamic_cast<QCheckListItem *>(lb_fktliste->currentItem()); + QString const fstr = currentItem->text(); + if ( !m_view->parser()->sendFunction(getId( currentItem->text()) ) ) + return; + slotDelete(); +} diff --git a/kmplot/kmplot/FktDlg.h b/kmplot/kmplot/FktDlg.h new file mode 100644 index 00000000..84908316 --- /dev/null +++ b/kmplot/kmplot/FktDlg.h @@ -0,0 +1,119 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +/** @file FktDlg.h + * @brief Contains the FktDlg class. Entering and editing functions equation and attributes. + */ + +#ifndef FktDlg_included +#define FktDlg_included + +// locale includes +#include "FktDlgData.h" +#include "View.h" + +class XParser; + +/** @short This widget class handles the users function input. + * + * The list of stored plots is shown. The entries can be edited and/or removed. + * New plots can be entered calling special dialog windows. + * @see KEditFunction, KEditParametric, KEditPolar + */ +class FktDlg : public FktDlgData +{ + Q_OBJECT + +public: + /** + * The constructor gets the current parser instance + * @param parent Parent widget. + * @param view points to the current view instance. + */ + FktDlg( QWidget* parent, View* view ); + /// Empty destructor. + virtual ~FktDlg(); + /// Fill the widgets with plots contained in the parser instance. + void getPlots(); + /// Returns true if a function was changed + bool isChanged(); + +public slots: + /// Pressed on the "Copy Function.." button + void slotCopyFunction(); + /// Pressed on the "Move Function.." button + void slotMoveFunction(); +protected slots: + /// Delete selected plot + void slotDelete(); + /// Edit selected Plot + void slotEdit(); + /// Enables/disables actions if the list has a/no selection. + void slotHasSelection(); + void lb_fktliste_doubleClicked(QListViewItem *, const QPoint &, int); + void lb_fktliste_clicked(QListViewItem * item); + void lb_fktliste_spacePressed(QListViewItem * item); + + /// Edit a function plot. + /// @param id Id of the function plot to edit + /// @see KEditFunction + void slotEditFunction( int id = -1 ); + /// Edit a parametric plot. + /// @param x_id Function index to edit + /// @param y_id Function index to edit + /// @see KEditParametric + void slotEditParametric( int x_id = -1, int y_id = -1 ); + /// Edit a polar plot. + /// @param id Function index of the parser instance. + /// @see KEditPolar + void slotEditPolar( int id = -1 ); + /// Edit a new function plot. + void slotNewFunction(); + /// Edit a new parametric plot. + void slotNewParametric(); + /// Edit a new polar plot. + void slotNewPolar(); + /// Invoke Help + void slotHelp(); + +private: + /// Looks up the id of \a f_str in the parser instance. + int getId( const QString &f_str ); + /// Looks up the indices of the parametric pair of function. + int getParamId( const QString &f_str ); + /// Update the view of the main window. + void updateView(); + /// Called when the dialog is showed + void showEvent ( QShowEvent * ); + // /// Send a function to an other instance of Kmplot. Returns true if it success, otherwise false + // bool sendFunction(); + + /// Ponts to the parser instance. + View* m_view; + /// indicates if a function is changed/added/removed + bool changed; +}; + +#endif // FktDlg_included diff --git a/kmplot/kmplot/FktDlgData.ui b/kmplot/kmplot/FktDlgData.ui new file mode 100644 index 00000000..9678e889 --- /dev/null +++ b/kmplot/kmplot/FktDlgData.ui @@ -0,0 +1,424 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>FktDlgData</class> +<widget class="QDialog"> + <property name="name"> + <cstring>FktDlgData</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>462</width> + <height>355</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>350</width> + <height>250</height> + </size> + </property> + <property name="caption"> + <string>Edit Plots</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButtonHelp</cstring> + </property> + <property name="text"> + <string>&Help</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>PushButtonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="toolTip" stdset="0"> + <string>apply the changes and close the dialog</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to apply your changes and close this dialog.</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButtonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="toolTip" stdset="0"> + <string>cancel without any changes</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to close the dialog without any changes.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QFrame" row="0" column="0"> + <property name="name"> + <cstring>frame5</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KListView" row="0" column="0" rowspan="9" colspan="1"> + <property name="name"> + <cstring>lb_fktliste</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="toolTip" stdset="0"> + <string>list of functions to be plotted</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Here you see the list of all functions to be plotted. The checked functions are visible, the others are hidden. Click on a checkbox to show or hide the function.</string> + </property> + </widget> + <widget class="QPushButton" row="4" column="1"> + <property name="name"> + <cstring>PushButtonDel</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Delete</string> + </property> + <property name="toolTip" stdset="0"> + <string>delete the selected function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to delete the selected function from the list.</string> + </property> + </widget> + <widget class="QPushButton" row="3" column="1"> + <property name="name"> + <cstring>PushButtonEdit</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Edit...</string> + </property> + <property name="toolTip" stdset="0"> + <string>edit the selected function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to edit the selected function.</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="1"> + <property name="name"> + <cstring>PushButtonNewFunction</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Ne&w Function Plot...</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>define a new function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to define a new function. There are 3 types of function, explicit given functions, parametric plots and polar plots. Choose the appropriate type from the drop down list.</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>PushButtonNewParametric</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>New &Parametric Plot...</string> + </property> + <property name="toolTip" stdset="0"> + <string>define a new function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to define a new function. There are 3 types of function, explicit given functions, parametric plots and polar plots. Choose the appropriate type from the drop down list.</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="1"> + <property name="name"> + <cstring>PushButtonNewPolar</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&New Polar Plot...</string> + </property> + <property name="toolTip" stdset="0"> + <string>define a new function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to define a new function. There are 3 types of function, explicit given functions, parametric plots and polar plots. Choose the appropriate type from the drop down list.</string> + </property> + </widget> + <spacer row="8" column="1"> + <property name="name"> + <cstring>Spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton" row="6" column="1"> + <property name="name"> + <cstring>cmdCopyFunction</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Cop&y Function...</string> + </property> + <property name="toolTip" stdset="0"> + <string>define a new function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to define a new function. There are 3 types of function, explicit given functions, parametric plots and polar plots. Choose the appropriate type from the drop down list.</string> + </property> + </widget> + <widget class="QPushButton" row="7" column="1"> + <property name="name"> + <cstring>cmdMoveFunction</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Move Function...</string> + </property> + <property name="toolTip" stdset="0"> + <string>define a new function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to define a new function. There are 3 types of function, explicit given functions, parametric plots and polar plots. Choose the appropriate type from the drop down list.</string> + </property> + </widget> + <spacer row="5" column="1"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>PushButtonDel</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>slotDelete()</slot> + </connection> + <connection> + <sender>lb_fktliste</sender> + <signal>selectionChanged()</signal> + <receiver>FktDlgData</receiver> + <slot>slotHasSelection()</slot> + </connection> + <connection> + <sender>PushButtonOk</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>pushButtonCancel</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>PushButtonEdit</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>slotEdit()</slot> + </connection> + <connection> + <sender>PushButtonNewFunction</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>slotNewFunction()</slot> + </connection> + <connection> + <sender>PushButtonNewParametric</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>slotNewParametric()</slot> + </connection> + <connection> + <sender>PushButtonNewPolar</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>slotNewPolar()</slot> + </connection> + <connection> + <sender>pushButtonHelp</sender> + <signal>clicked()</signal> + <receiver>FktDlgData</receiver> + <slot>slotHelp()</slot> + </connection> +</connections> +<tabstops> + <tabstop>lb_fktliste</tabstop> + <tabstop>PushButtonNewFunction</tabstop> + <tabstop>PushButtonNewParametric</tabstop> + <tabstop>PushButtonNewPolar</tabstop> + <tabstop>PushButtonEdit</tabstop> + <tabstop>PushButtonDel</tabstop> + <tabstop>PushButtonOk</tabstop> + <tabstop>pushButtonCancel</tabstop> + <tabstop>pushButtonHelp</tabstop> +</tabstops> +<slots> + <slot>slotDelete()</slot> + <slot>slotEdit()</slot> + <slot>slotHasSelection()</slot> + <slot>slotNewParametric()</slot> + <slot>slotNewPolar()</slot> + <slot>slotNewFunction()</slot> + <slot access="protected">slotHelp()</slot> + <slot>slotNewPrime()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistview.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/MainDlg.cpp b/kmplot/kmplot/MainDlg.cpp new file mode 100644 index 00000000..c148d3a2 --- /dev/null +++ b/kmplot/kmplot/MainDlg.cpp @@ -0,0 +1,830 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kdmoeller@foni.net +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +// Qt includes +#include <qslider.h> +#include <qtooltip.h> + +// KDE includes +#include <dcopclient.h> +#include <kaboutdata.h> +#include <kapplication.h> +#include <kconfigdialog.h> +#include <kdebug.h> +#include <kedittoolbar.h> +#include <kio/netaccess.h> +#include <kinstance.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <ktempfile.h> +#include <ktoolbar.h> + + +// local includes +#include "editfunction.h" +#include "keditparametric.h" +#include "keditpolar.h" +#include "kprinterdlg.h" +#include "kconstanteditor.h" +#include "MainDlg.h" +#include "MainDlg.moc" +#include "settings.h" +#include "settingspagecolor.h" +#include "settingspagefonts.h" +#include "settingspageprecision.h" +#include "settingspagescaling.h" +#include "ksliderwindow.h" + +class XParser; +class KmPlotIO; + +bool MainDlg::oldfileversion; + +MainDlg::MainDlg(QWidget *parentWidget, const char *, QObject *parent, const char *name) : DCOPObject( "MainDlg" ), KParts::ReadOnlyPart( parent, name ), m_recentFiles( 0 ), m_modified(false), m_parent(parentWidget) +{ + // we need an instance + setInstance( KmPlotPartFactory::instance() ); + + kdDebug() << "parentWidget->name():" << parentWidget->name() << endl; + if ( QString(parentWidget->name()).startsWith("KmPlot") ) + { + setXMLFile("kmplot_part.rc"); + m_readonly = false; + } + else + { + setXMLFile("kmplot_part_readonly.rc"); + m_readonly = true; + new BrowserExtension(this); // better integration with Konqueror + } + fdlg = 0; + coordsDialog = 0; + m_popupmenu = new KPopupMenu(parentWidget); + view = new View( m_readonly, m_modified, m_popupmenu, parentWidget ); + connect( view, SIGNAL( setStatusBarText(const QString &)), this, SLOT( setReadOnlyStatusBarText(const QString &) ) ); + setWidget( view ); + view->setFocusPolicy(QWidget::ClickFocus); + minmaxdlg = new KMinMax(view, m_parent); + view->setMinMaxDlg(minmaxdlg); + m_quickEdit = new KLineEdit( parentWidget ); + m_quickEdit->setFocus(); + QToolTip::add( m_quickEdit, i18n( "Enter a function equation, for example: f(x)=x^2" ) ); + setupActions(); + loadConstants(); + kmplotio = new KmPlotIO(view->parser()); + m_config = kapp->config(); + m_recentFiles->loadEntries( m_config ); + + // Let's create a Configure Diloag + m_settingsDialog = new KConfigDialog( parentWidget, "settings", Settings::self() ); + m_settingsDialog->setHelp("general-config"); + + // create and add the page(s) + m_generalSettings = new SettingsPagePrecision( 0, "precisionSettings", "precision" ); + m_constantsSettings = new KConstantEditor( view, 0, "constantsSettings" ); + m_settingsDialog->addPage( m_generalSettings, i18n("General"), "package_settings", i18n("General Settings") ); + m_settingsDialog->addPage( m_constantsSettings, i18n("Constants"), "editconstants", i18n("Constants") ); + // User edited the configuration - update your local copies of the + // configuration data + connect( m_settingsDialog, SIGNAL( settingsChanged() ), this, SLOT(updateSettings() ) ); + connect( view, SIGNAL( resetZoom() ), this, SLOT(resetZoom() ) ); +} + +MainDlg::~MainDlg() +{ + m_recentFiles->saveEntries( m_config ); + saveConstants(); + delete kmplotio; +} + +void MainDlg::setupActions() +{ + // standard actions + m_recentFiles = KStdAction::openRecent( this, SLOT( slotOpenRecent( const KURL& ) ), actionCollection(),"file_openrecent"); + KStdAction::print( this, SLOT( slotPrint() ), actionCollection(),"file_print" ); + KStdAction::save( this, SLOT( slotSave() ), actionCollection() ); + KStdAction::saveAs( this, SLOT( slotSaveas() ), actionCollection() ); + connect( kapp, SIGNAL( lastWindowClosed() ), kapp, SLOT( quit() ) ); + + KAction *prefs = KStdAction::preferences( this, SLOT( slotSettings() ), actionCollection()); + prefs->setText( i18n( "Configure KmPlot..." ) ); + KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection()); + KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); + + + // KmPlot specific actions + // file menu + ( void ) new KAction( i18n( "E&xport..." ), 0, this, SLOT( slotExport() ), actionCollection(), "export"); + + //zoom menu + m_mnuNoZoom = new KRadioAction(i18n("&No Zoom") ,"CTRL+0",view, SLOT( mnuNoZoom_clicked() ),actionCollection(),"no_zoom" ); + KRadioAction * mnuRectangular = new KRadioAction(i18n("Zoom &Rectangular"), "viewmagfit", "CTRL+1",view, SLOT( mnuRectangular_clicked() ),actionCollection(),"zoom_rectangular" ); + KRadioAction * mnuZoomIn = new KRadioAction(i18n("Zoom &In"), "viewmag+", "CTRL+2",view, SLOT( mnuZoomIn_clicked() ),actionCollection(),"zoom_in" ); + KRadioAction * mnuZoomOut = new KRadioAction(i18n("Zoom &Out"), "viewmag-", "CTRL+3",view, SLOT( mnuZoomOut_clicked() ),actionCollection(),"zoom_out" ); + KRadioAction * mnuZoomCenter = new KRadioAction(i18n("&Center Point") ,"CTRL+4",view, SLOT( mnuCenter_clicked() ),actionCollection(),"zoom_center" ); + (void ) new KAction(i18n("&Fit Widget to Trigonometric Functions") ,0,view, SLOT( mnuTrig_clicked() ),actionCollection(),"zoom_trig" ); + m_mnuNoZoom->setExclusiveGroup("zoom_modes"); + m_mnuNoZoom->setChecked(true); + mnuRectangular->setExclusiveGroup("zoom_modes"); + mnuZoomIn->setExclusiveGroup("zoom_modes"); + mnuZoomOut->setExclusiveGroup("zoom_modes"); + mnuZoomCenter->setExclusiveGroup("zoom_modes"); + + // help menu + ( void ) new KAction( i18n( "Predefined &Math Functions" ), "functionhelp", 0, this, SLOT( slotNames() ), actionCollection(), "names" ); + + // edit menu + ( void ) new KAction( i18n( "&Colors..." ), "colorize.png", 0, this, SLOT( editColors() ), actionCollection(), "editcolors" ); + ( void ) new KAction( i18n( "&Coordinate System..." ), "coords.png", 0, this, SLOT( editAxes() ), actionCollection(), "editaxes" ); + // ( void ) new KAction( i18n( "&Grid..." ), "coords.png", 0, this, SLOT( editGrid() ), actionCollection(), "editgrid" ); + ( void ) new KAction( i18n( "&Scaling..." ), "scaling", 0, this, SLOT( editScaling() ), actionCollection(), "editscaling" ); + ( void ) new KAction( i18n( "&Fonts..." ), "fonts", 0, this, SLOT( editFonts() ), actionCollection(), "editfonts" ); + + ( void ) new KAction( i18n( "Coordinate System I" ), "ksys1.png", 0, this, SLOT( slotCoord1() ), actionCollection(), "coord_i" ); + ( void ) new KAction( i18n( "Coordinate System II" ), "ksys2.png", 0, this, SLOT( slotCoord2() ), actionCollection(), "coord_ii" ); + ( void ) new KAction( i18n( "Coordinate System III" ), "ksys3.png", 0, this, SLOT( slotCoord3() ), actionCollection(), "coord_iii" ); + + // plot menu + ( void ) new KAction( i18n( "&New Function Plot..." ), "newfunction", 0, this, SLOT( newFunction() ), actionCollection(), "newfunction" ); + ( void ) new KAction( i18n( "New Parametric Plot..." ), "newparametric", 0, this, SLOT( newParametric() ), actionCollection(), "newparametric" ); + ( void ) new KAction( i18n( "New Polar Plot..." ), "newpolar", 0, this, SLOT( newPolar() ), actionCollection(), "newpolar" ); + ( void ) new KAction( i18n( "Edit Plots..." ), "editplots", 0, this, SLOT( slotEditPlots() ), actionCollection(), "editplots" ); + + // tools menu + KAction *mnuYValue = new KAction( i18n( "&Get y-Value..." ), 0, this, SLOT( getYValue() ), actionCollection(), "yvalue" ); + KAction *mnuMinValue = new KAction( i18n( "&Search for Minimum Value..." ), "minimum", 0, this, SLOT( findMinimumValue() ), actionCollection(), "minimumvalue" ); + KAction *mnuMaxValue = new KAction( i18n( "&Search for Maximum Value..." ), "maximum", 0, this, SLOT( findMaximumValue() ), actionCollection(), "maximumvalue" ); + KAction *mnuArea = new KAction( i18n( "&Calculate Integral" ), 0, this, SLOT( graphArea() ), actionCollection(), "grapharea" ); + + connect( m_quickEdit, SIGNAL( returnPressed( const QString& ) ), this, SLOT( slotQuickEdit( const QString& ) ) ); + KWidgetAction* quickEditAction = new KWidgetAction( m_quickEdit, i18n( "Quick Edit" ), 0, this, 0, actionCollection(), "quickedit" ); + quickEditAction->setWhatsThis( i18n( "Enter a simple function equation here.\n" + "For instance: f(x)=x^2\nFor more options use Functions->Edit Plots... menu." ) ); + + view->mnuSliders[0] = new KToggleAction( i18n( "Show Slider 1" ), 0, this, SLOT( toggleShowSlider0() ), actionCollection(), QString( "options_configure_show_slider_0" ).latin1() ); + view->mnuSliders[1] = new KToggleAction( i18n( "Show Slider 2" ), 0, this, SLOT( toggleShowSlider1() ), actionCollection(), QString( "options_configure_show_slider_1" ).latin1() ); + view->mnuSliders[2] = new KToggleAction( i18n( "Show Slider 3" ), 0, this, SLOT( toggleShowSlider2() ), actionCollection(), QString( "options_configure_show_slider_2" ).latin1() ); + view->mnuSliders[3] = new KToggleAction( i18n( "Show Slider 4" ), 0, this, SLOT( toggleShowSlider3() ), actionCollection(), QString( "options_configure_show_slider_3" ).latin1() ); + + // Popup menu + KAction *mnuHide = new KAction(i18n("&Hide") ,0,view, SLOT( mnuHide_clicked() ),actionCollection(),"mnuhide" ); + mnuHide->plug(m_popupmenu); + KAction *mnuRemove = new KAction(i18n("&Remove"),"editdelete", 0,view, SLOT( mnuRemove_clicked() ),actionCollection(),"mnuremove" ); + mnuRemove->plug(m_popupmenu); + KAction *mnuEdit = new KAction(i18n("&Edit"),"editplots", 0,view, SLOT( mnuEdit_clicked() ),actionCollection(),"mnuedit" ); + mnuEdit->plug(m_popupmenu); + m_popupmenu->insertSeparator(); + KAction *mnuCopy = new KAction(i18n("&Copy"), 0,view, SLOT( mnuCopy_clicked() ),actionCollection(),"mnucopy" ); + mnuCopy->plug(m_popupmenu); + KAction *mnuMove = new KAction(i18n("&Move"), 0,view, SLOT( mnuMove_clicked() ),actionCollection(),"mnumove" ); + mnuMove->plug(m_popupmenu); + m_popupmenu->insertSeparator(); + mnuYValue->plug(m_popupmenu); + mnuMinValue->plug(m_popupmenu); + mnuMaxValue->plug(m_popupmenu); + mnuArea->plug(m_popupmenu); +} +bool MainDlg::checkModified() +{ + if( m_modified ) + { + int saveit = KMessageBox::warningYesNoCancel( m_parent, i18n( "The plot has been modified.\n" + "Do you want to save it?" ), QString::null, KStdGuiItem::save(), KStdGuiItem::discard() ); + switch( saveit ) + { + case KMessageBox::Yes: + slotSave(); + if ( m_modified) // the user didn't saved the file + return false; + break; + case KMessageBox::Cancel: + return false; + } + } + return true; +} +/* +void MainDlg::slotCleanWindow() +{ + if (m_readonly) + return; + view->init(); // set globals to default + view->updateSliders(); + view->drawPlot(); +} +*/ +void MainDlg::slotSave() +{ + if ( !m_modified || m_readonly) //don't save if no changes are made or readonly is enabled + return; + if ( m_url.isEmpty() ) // if there is no file name set yet + slotSaveas(); + else + { + if ( !m_modified) //don't save if no changes are made + return; + + if ( oldfileversion) + { + if ( KMessageBox::warningContinueCancel( m_parent, i18n( "This file is saved with an old file format; if you save it, you cannot open the file with older versions of Kmplot. Are you sure you want to continue?" ), QString::null, i18n("Save New Format") ) == KMessageBox::Cancel) + return; + } + kmplotio->save( m_url.url() ); + kdDebug() << "saved" << endl; + m_modified = false; + } + +} + +void MainDlg::slotSaveas() +{ + if (m_readonly) + return; + const KURL url = KFileDialog::getSaveURL( QDir::currentDirPath(), i18n( "*.fkt|KmPlot Files (*.fkt)\n*|All Files" ), m_parent, i18n( "Save As" ) ); + + if ( !url.isEmpty() ) + { + // check if file exists and overwriting is ok. + if( !KIO::NetAccess::exists( url,false,m_parent ) || KMessageBox::warningContinueCancel( m_parent, i18n( "A file named \"%1\" already exists. Are you sure you want to continue and overwrite this file?" ).arg( url.url()), i18n( "Overwrite File?" ), KGuiItem( i18n( "&Overwrite" ) ) ) == KMessageBox::Continue ) + { + if ( !kmplotio->save( url ) ) + KMessageBox::error(m_parent, i18n("The file could not be saved") ); + else + { + m_url = url; + m_recentFiles->addURL( url ); + setWindowCaption( m_url.prettyURL(0, KURL::StripFileProtocol) ); + m_modified = false; + } + return; + } + } +} + +void MainDlg::slotExport() +{ + KURL const url = KFileDialog::getSaveURL(QDir::currentDirPath(), + i18n("*.svg|Scalable Vector Graphics (*.svg)\n" + "*.bmp|Bitmap 180dpi (*.bmp)\n" + "*.png|Bitmap 180dpi (*.png)"), m_parent, i18n("Export") ); + if(!url.isEmpty()) + { + // check if file exists and overwriting is ok. + if( KIO::NetAccess::exists(url,false,m_parent ) && KMessageBox::warningContinueCancel( m_parent, i18n( "A file named \"%1\" already exists. Are you sure you want to continue and overwrite this file?" ).arg(url.url() ), i18n( "Overwrite File?" ), KGuiItem( i18n( "&Overwrite" ) ) ) != KMessageBox::Continue ) return; + + if( url.fileName().right(4).lower()==".svg") + { + QPicture pic; + view->draw(&pic, 2); + if (url.isLocalFile() ) + pic.save( url.prettyURL(0,KURL::StripFileProtocol), "SVG"); + else + { + KTempFile tmp; + pic.save( tmp.name(), "SVG"); + if ( !KIO::NetAccess::upload(tmp.name(), url, 0) ) + KMessageBox::error(m_parent, i18n("The URL could not be saved.") ); + tmp.unlink(); + } + } + + else if( url.fileName().right(4).lower()==".bmp") + { + QPixmap pic(100, 100); + view->draw(&pic, 3); + if (url.isLocalFile() ) + pic.save( url.prettyURL(0,KURL::StripFileProtocol), "BMP"); + else + { + KTempFile tmp; + pic.save( tmp.name(), "BMP"); + if ( !KIO::NetAccess::upload(tmp.name(), url, 0) ) + KMessageBox::error(m_parent, i18n("The URL could not be saved.") ); + tmp.unlink(); + } + } + + else if( url.fileName().right(4).lower()==".png") + { + QPixmap pic(100, 100); + view->draw(&pic, 3); + if (url.isLocalFile() ) + pic.save( url.prettyURL(0,KURL::StripFileProtocol), "PNG"); + else + { + KTempFile tmp; + pic.save( tmp.name(), "PNG"); + if ( !KIO::NetAccess::upload(tmp.name(), url, 0) ) + KMessageBox::error(m_parent, i18n("The URL could not be saved.") ); + tmp.unlink(); + } + } + } +} +bool MainDlg::openFile() +{ + view->init(); + if (m_url==m_currentfile || !kmplotio->load( m_url ) ) + { + m_recentFiles->removeURL(m_url ); //remove the file from the recent-opened-file-list + m_url = ""; + return false; + } + m_currentfile = m_url; + m_recentFiles->addURL( m_url.prettyURL(0, KURL::StripFileProtocol) ); + setWindowCaption( m_url.prettyURL(0, KURL::StripFileProtocol) ); + m_modified = false; + view->updateSliders(); + view->drawPlot(); + return true; +} + +void MainDlg::slotOpenRecent( const KURL &url ) +{ + if( isModified() || !m_url.isEmpty() ) // open the file in a new window + { + QByteArray data; + QDataStream stream(data, IO_WriteOnly); + stream << url; + KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","openFileInNewWindow(KURL)", data); + return; + } + + view->init(); + if ( !kmplotio->load( url ) ) //if the loading fails + { + m_recentFiles->removeURL(url ); //remove the file from the recent-opened-file-list + return; + } + m_url = m_currentfile = url; + m_recentFiles->setCurrentItem(-1); //don't select the item in the open-recent menu + setWindowCaption( m_url.prettyURL(0, KURL::StripFileProtocol) ); + m_modified = false; + view->updateSliders(); + view->drawPlot(); +} + +void MainDlg::slotPrint() +{ + KPrinter prt( QPrinter::PrinterResolution ); + prt.setResolution( 72 ); + prt.addDialogPage( new KPrinterDlg( m_parent, "KmPlot page" ) ); + if ( prt.setup( m_parent, i18n( "Print Plot" ) ) ) + { + prt.setFullPage( true ); + view->draw(&prt, 1); + } +} + +void MainDlg::editColors() +{ + // create a config dialog and add a colors page + KConfigDialog* colorsDialog = new KConfigDialog( m_parent, "colors", Settings::self() ); + colorsDialog->setHelp("color-config"); + colorsDialog->addPage( new SettingsPageColor( 0, "colorSettings" ), i18n( "Colors" ), "colorize", i18n( "Edit Colors" ) ); + + // User edited the configuration - update your local copies of the + // configuration data + connect( colorsDialog, SIGNAL( settingsChanged() ), this, SLOT(updateSettings() ) ); + colorsDialog->show(); +} + +void MainDlg::editAxes() +{ + // create a config dialog and add a axes page + if ( !coordsDialog) + { + coordsDialog = new CoordsConfigDialog( view->parser(), m_parent); + // User edited the configuration - update your local copies of the + // configuration data + connect( coordsDialog, SIGNAL( settingsChanged() ), this, SLOT(updateSettings() ) ); + } + coordsDialog->show(); +} + +void MainDlg::editScaling() +{ + // create a config dialog and add a scaling page + KConfigDialog *scalingDialog = new KConfigDialog( m_parent, "scaling", Settings::self() ); + scalingDialog->setHelp("scaling-config"); + scalingDialog->addPage( new SettingsPageScaling( 0, "scalingSettings" ), i18n( "Scale" ), "scaling", i18n( "Edit Scaling" ) ); + // User edited the configuration - update your local copies of the + // configuration data + connect( scalingDialog, SIGNAL( settingsChanged() ), this, SLOT(updateSettings() ) ); + scalingDialog->show(); +} + +void MainDlg::editFonts() +{ + // create a config dialog and add a font page + KConfigDialog* fontsDialog = new KConfigDialog( m_parent, "fonts", Settings::self() ); + fontsDialog->setHelp("font-config"); + fontsDialog->addPage( new SettingsPageFonts( 0, "fontsSettings" ), i18n( "Fonts" ), "fonts", i18n( "Edit Fonts" ) ); + // User edited the configuration - update your local copies of the + // configuration data + connect( fontsDialog, SIGNAL( settingsChanged() ), this, SLOT(updateSettings() ) ); + fontsDialog->show(); +} + +void MainDlg::editConstants() +{ + QConstantEditor* contsDialog = new QConstantEditor(); + contsDialog->show(); +} + +void MainDlg::slotNames() +{ + kapp->invokeHelp( "func-predefined", "kmplot" ); +} + +void MainDlg::newFunction() +{ + EditFunction* editFunction = new EditFunction( view->parser(), m_parent ); + editFunction->setCaption(i18n( "New Function Plot" ) ); + editFunction->initDialog(); + if ( editFunction->exec() == QDialog::Accepted ) + { + m_modified = true; + view->updateSliders(); + view->drawPlot(); + } +} + +void MainDlg::newParametric() +{ + KEditParametric* editParametric = new KEditParametric( view->parser(), m_parent ); + editParametric->setCaption(i18n( "New Parametric Plot")); + editParametric->initDialog(); + if ( editParametric->exec() == QDialog::Accepted ) + { + m_modified = true; + view->drawPlot(); + } + +} + +void MainDlg::newPolar() +{ + KEditPolar* editPolar = new KEditPolar( view->parser(), m_parent ); + editPolar->setCaption(i18n( "New Polar Plot")); + editPolar->initDialog(); + if ( editPolar->exec() == QDialog::Accepted ) + { + m_modified = true; + view->drawPlot(); + } + +} + +void MainDlg::slotEditPlots() +{ + if ( !fdlg ) fdlg = new FktDlg( m_parent, view ); // make the dialog only if not allready done + fdlg->getPlots(); + KTempFile tmpfile; + kmplotio->save( tmpfile.name() ); + if( fdlg->exec() == QDialog::Rejected ) + { + if ( fdlg->isChanged() ) + { + view->init(); + kmplotio->load( tmpfile.name() ); + view->drawPlot(); + } + } + else if ( fdlg->isChanged() ) + { + view->updateSliders(); + m_modified = true; + } + tmpfile.unlink(); +} + +void MainDlg::slotQuickEdit(const QString& f_str_const ) +{ + //creates a valid name for the function if the user has forgotten that + QString f_str( f_str_const ); + int const pos = f_str_const.find(';'); + if (pos!=-1) + f_str = f_str.left(pos); + if (f_str.at(0)=='r') + view->parser()->fixFunctionName(f_str, XParser::Polar); + else + view->parser()->fixFunctionName(f_str); + if ( f_str.at(0)== 'x' || f_str.at(0)== 'y') + { + KMessageBox::error( m_parent, i18n("Parametric functions must be definied in the \"New Parametric Plot\"-dialog which you can find in the menubar")); + return; + } + if ( f_str.contains('y') != 0) + { + KMessageBox::error( m_parent, i18n( "Recursive function is not allowed")); + m_quickEdit->setFocus(); + m_quickEdit->selectAll(); + return; + } + + int const id = view->parser()->addfkt( f_str ); + if (id==-1) + { + view->parser()->parserError(); + m_quickEdit->setFocus(); + m_quickEdit->selectAll(); + return; + } + Ufkt *ufkt = &view->parser()->ufkt.last(); + view->parser()->prepareAddingFunction(ufkt); + + if ( pos!=-1 && !view->parser()->getext(ufkt, QString(f_str_const))) + { + m_quickEdit->setFocus(); + m_quickEdit->selectAll(); + view->parser()->Parser::delfkt( ufkt ); + return; + } + m_quickEdit->clear(); + m_modified = true; + view->drawPlot(); +} + + +void MainDlg::slotCoord1() +{ + Settings::setXRange( 0 ); + Settings::setYRange( 0 ); + m_modified = true; + view->drawPlot(); +} + +void MainDlg::slotCoord2() +{ + Settings::setXRange( 2 ); + Settings::setYRange( 0 ); + m_modified = true; + view->drawPlot(); +} + +void MainDlg::slotCoord3() +{ + Settings::setXRange( 2 ); + Settings::setYRange( 2 ); + m_modified = true; + view->drawPlot(); +} + +void MainDlg::slotSettings() +{ + // An instance of your dialog has already been created and has been cached, + // so we want to display the cached dialog instead of creating + // another one + KConfigDialog::showDialog( "settings" ); +} + +void MainDlg::updateSettings() +{ + view->getSettings(); + m_modified = true; + view->drawPlot(); +} + +void MainDlg::loadConstants() +{ + KSimpleConfig conf ("kcalcrc"); + conf.setGroup("UserConstants"); + QString tmp; + QString tmp_constant; + QString tmp_value; + char constant; + double value; + for( int i=0; ;i++) + { + tmp.setNum(i); + tmp_constant = conf.readEntry("nameConstant"+tmp," "); + tmp_value = conf.readEntry("valueConstant"+tmp," "); +// kdDebug() << "konstant: " << tmp_constant.latin1() << endl; +// kdDebug() << "value: " << value << endl; +// kdDebug() << "**************" << endl; + + if ( tmp_constant == " " || tmp_constant == " ") + return; + + constant = tmp_constant.at(0).upper().latin1(); + + if ( constant<'A' || constant>'Z') + constant = 'A'; + value = view->parser()->eval(tmp_value); + if ( view->parser()->parserError(false) ) //couln't parse the value + continue; + + if ( !view->parser()->constant.empty() ) + { + bool copy_found=false; + while (!copy_found) + { + // go through the constant list + QValueVector<Constant>::iterator it = view->parser()->constant.begin(); + while (it!= view->parser()->constant.end() && !copy_found) + { + if (constant == it->constant ) + copy_found = true; + else + ++it; + } + if ( !copy_found) + copy_found = true; + else + { + copy_found = false; + if (constant == 'Z') + constant = 'A'; + else + constant++; + } + } + } + /*kdDebug() << "**************" << endl; + kdDebug() << "C:" << constant << endl; + kdDebug() << "V:" << value << endl;*/ + + view->parser()->constant.append(Constant(constant, value) ); + } +} + +void MainDlg::saveConstants() +{ + KSimpleConfig conf ("kcalcrc"); + conf.deleteGroup("Constants"); + conf.setGroup("UserConstants"); + QString tmp; + for( int i = 0; i< (int)view->parser()->constant.size();i++) + { + tmp.setNum(i); + conf.writeEntry("nameConstant"+tmp, QString( QChar(view->parser()->constant[i].constant) ) ) ; + conf.writeEntry("valueConstant"+tmp, view->parser()->constant[i].value); + } +} + +void MainDlg::getYValue() +{ + minmaxdlg->init(2); + minmaxdlg->show(); +} + +void MainDlg::findMinimumValue() +{ + minmaxdlg->init(0); + minmaxdlg->show(); +} + +void MainDlg::findMaximumValue() +{ + minmaxdlg->init(1); + minmaxdlg->show(); +} + +void MainDlg::graphArea() +{ + minmaxdlg->init(3); + minmaxdlg->show(); +} + +void MainDlg::toggleShowSlider0() +{ + toggleShowSlider(0); +} + +void MainDlg::toggleShowSlider1() +{ + toggleShowSlider(1); +} + +void MainDlg::toggleShowSlider2() +{ + toggleShowSlider(2); +} + +void MainDlg::toggleShowSlider3() +{ + toggleShowSlider(3); +} + +void MainDlg::toggleShowSlider(int const num) +{ + // create the slider if it not exists already + if ( view->sliders[ num ] == 0 ) + { + view->sliders[ num ] = new KSliderWindow( view, num); + connect( view->sliders[num]->slider, SIGNAL( valueChanged( int ) ), view, SLOT( drawPlot() ) ); + connect( view->sliders[num], SIGNAL( windowClosed( int ) ), view, SLOT( sliderWindowClosed(int) ) ); + } + if ( !view->sliders[ num ]->isShown() ) + view->sliders[ num ]->show(); + else + view->sliders[ num ]->hide(); +} + +void MainDlg::setReadOnlyStatusBarText(const QString &text) +{ + setStatusBarText(text); +} + +void MainDlg::optionsConfigureKeys() +{ + KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","optionsConfigureKeys()", QByteArray()); +} + +void MainDlg::optionsConfigureToolbars() +{ + KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","optionsConfigureToolbars()", QByteArray()); +} + +void MainDlg::resetZoom() +{ + m_mnuNoZoom->activate(); +} + +// It's usually safe to leave the factory code alone.. with the +// notable exception of the KAboutData data +#include <kaboutdata.h> +#include <klocale.h> + +KInstance* KmPlotPartFactory::s_instance = 0L; +KAboutData* KmPlotPartFactory::s_about = 0L; + +KmPlotPartFactory::KmPlotPartFactory() + : KParts::Factory() +{} + +KmPlotPartFactory::~KmPlotPartFactory() +{ + delete s_instance; + delete s_about; + + s_instance = 0L; +} + +KParts::Part* KmPlotPartFactory::createPartObject( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const char *, const QStringList & ) +{ + // Create an instance of our Part + MainDlg* obj = new MainDlg( parentWidget, widgetName, parent, name ); + emit objectCreated( obj ); + return obj; +} + +KInstance* KmPlotPartFactory::instance() +{ + if( !s_instance ) + { + s_about = new KAboutData("kmplot",I18N_NOOP( "KmPlotPart" ), "1"); + s_instance = new KInstance(s_about); + } + return s_instance; +} + +extern "C" +{ + KDE_EXPORT void* init_libkmplotpart() + { + return new KmPlotPartFactory; + } +} + + +/// BrowserExtension class +BrowserExtension::BrowserExtension(MainDlg* parent) + : KParts::BrowserExtension( parent, "KmPlot::BrowserExtension" ) +{ + emit enableAction("print", true); + setURLDropHandlingEnabled(true); +} + +void BrowserExtension::print() +{ + static_cast<MainDlg*>(parent())->slotPrint(); +} + + diff --git a/kmplot/kmplot/MainDlg.h b/kmplot/kmplot/MainDlg.h new file mode 100644 index 00000000..dd3a9916 --- /dev/null +++ b/kmplot/kmplot/MainDlg.h @@ -0,0 +1,243 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/** @file MainDlg.h + * @brief Contains the main window class MainDlg. */ + +#ifndef MainDlg_included +#define MainDlg_included + +// Qt includes +#include <qpicture.h> + +// KDE includes +#include <kaction.h> +#include <kfiledialog.h> +#include <kpopupmenu.h> +#include <kstandarddirs.h> +#include <kparts/browserextension.h> +#include <kparts/part.h> +#include <kparts/factory.h> + +#undef GrayScale + +// local includes +#include "coordsconfigdialog.h" +#include "FktDlg.h" +#include "View.h" +#include "kminmax.h" +#include "kmplotio.h" +#include "MainDlgIface.h" + +class KConfigDialog; +class KLineEdit; +class KRecentFilesAction; +class SettingsPageColor; +class SettingsPageFonts; +class SettingsPagePrecision; +class SettingsPageScaling; +class KConstantEditor; +class KToggleFullScreenAction; +class BrowserExtension; + + +/** @short This is the main window of KmPlot. + * + * Its central widget view contains the parser, accessable via its parser() function. + * @see View, View::m_parser, View::parser + */ +class MainDlg : public KParts::ReadOnlyPart, virtual public MainDlgIface +{ + Q_OBJECT + +public: + /** Constuctor. + * @param parentWidget parent widget for this part + * @param parent parent object + * @param name name of this dialog + */ + MainDlg(QWidget *parentWidget, const char *, QObject *parent, const char *name); + /// Cleaning up a bit. + virtual ~MainDlg(); + /// This class needs access to private members, too. + friend class FktDlg; + /// This class needs access to private members, too. + friend class BezWnd; + + /// Asks the user and returns true if modified data shall be dicarded. + bool checkModified(); + /// Is set to true if a file from an old file format was loaded + static bool oldfileversion; + +public slots: + /// Implement the color edit dialog + void editColors(); + /// Implement the coordinate system edit dialog + void editAxes(); + /// Implement the scaling edit dialog + void editScaling(); + /// Implement the fonts edit dialog + void editFonts(); + /// Implement the constants edit dialog + void editConstants(); + /// Implement the dialog to enter a function plot and its options + void newFunction(); + /// Implement the dialog to enter a parametric plot and its options + void newParametric(); + /// Implement the dialog to enter a polar plot and its options + void newPolar(); + /// Show/hide parameter slider windows + void toggleShowSlider0(); + void toggleShowSlider1(); + void toggleShowSlider2(); + void toggleShowSlider3(); + + // ///I'm not sure it a delete-all-functions command is necessary + // void slotCleanWindow(); + ///Save a plot i.e. save the function name and all the settings for the plot + void slotSave(); + ///Save a plot and choose a name for it + void slotSaveas(); + ///Call the dialog (an instance of FktDlg) to edit the functions and make changes on them + void slotEditPlots(); + ///Print the current plot + void slotPrint(); + ///Export the current plot as a png, svg or bmp picture + void slotExport(); + ///Implement the Configure KmPlot dialog + void slotSettings(); + /// Calls the common function names dialog. + /// @see BezWnd::hideEvent + void slotNames(); + /// Change the coordinate systems, shows negative x-values and negative y-values. + void slotCoord1(); + /// Change the coordinate systems, shows positive x-values and negative y-values. + void slotCoord2(); + /// Change the coordinate systems, shows positive x-values and positive y-values. + void slotCoord3(); + /// Tools menu + void getYValue(); + void findMinimumValue(); + void findMaximumValue(); + void graphArea(); + void resetZoom(); + +private: + /// Settings the standard and non standard actions of the application. + void setupActions(); + /// Called when a file is opened. The filename is is m_url + virtual bool openFile(); + /// Loading the constants by start + void loadConstants(); + /// Loading the constants when closing the program + void saveConstants(); + /// Returns true if any changes are done + bool isModified(){return m_modified;} + /// Toggle the slider with index num + void toggleShowSlider(int const num); + + /// Cached dialog to edit all functions + FktDlg *fdlg; + /// Central widget of the KMainWindow instance. tralala + View *view; + ///The Recent Files action + KRecentFilesAction * m_recentFiles; + /// true == modifications not saved + bool m_modified; + ///An instance of the application config file + KConfig* m_config; + ///The KLineEdit which is in the toolbar + KLineEdit* m_quickEdit; + ///A Configure KmPlot dialog instance + KConfigDialog* m_settingsDialog; + ///The Precision page for the Configure KmPlot dialog + SettingsPagePrecision* m_generalSettings; + ///The Constants page for the Configure KmPlot constants + KConstantEditor* m_constantsSettings; + + /// A dialog used by many tools-menu-items + KMinMax *minmaxdlg; + /// the popup menu shown when cling with the right mouse button on a graph in the graph widget + KPopupMenu *m_popupmenu; + /// Loads and saves the user's file. + KmPlotIO *kmplotio; + /// Set to true if the application is readonly + bool m_readonly; + /// MainDlg's parent widget + QWidget *m_parent; + /// Current file + KURL m_currentfile; + /// The axes config dialogs + CoordsConfigDialog* coordsDialog; + KRadioAction * m_mnuNoZoom; + +protected slots: + /** + * When you click on a File->Open Recent file, it'll open + * @param url name of the url to open + */ + void slotOpenRecent( const KURL &url ); + ///Update settings when there is a change in the Configure KmPlot dialog + void updateSettings(); + /** + * Manages the LineEdit content after returnPressed() is emitted. + * @param f_str_const the content of the KLineEdit + */ + void slotQuickEdit( const QString& f_str_const ); + + void setReadOnlyStatusBarText(const QString &); + + /// slots for the settings-menu + void optionsConfigureKeys(); + void optionsConfigureToolbars(); +}; + +class KmPlotPartFactory : public KParts::Factory +{ + Q_OBJECT +public: + KmPlotPartFactory(); + virtual ~KmPlotPartFactory(); + virtual KParts::Part* createPartObject( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const char *classname, const QStringList &args ); + static KInstance* instance(); + +private: + static KInstance* s_instance; + static KAboutData* s_about; +}; + +class BrowserExtension : public KParts::BrowserExtension +{ + Q_OBJECT +public: + BrowserExtension(MainDlg*); + +public slots: + // Automatically detected by the host. + void print(); +}; + +#endif // MainDlg_included diff --git a/kmplot/kmplot/MainDlgIface.h b/kmplot/kmplot/MainDlgIface.h new file mode 100644 index 00000000..c0431146 --- /dev/null +++ b/kmplot/kmplot/MainDlgIface.h @@ -0,0 +1,70 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef MAINDLGIFACE_H +#define MAINDLGIFACE_H + +#include <dcopobject.h> + +/** +@author Fredrik Edemar +*/ +/// All functions in MainDlgIface are accessible with DCOP. For descriptions about the functions, see MainDlg. +class MainDlgIface : virtual public DCOPObject +{ + K_DCOP +k_dcop: + virtual bool checkModified() = 0; + + virtual bool isModified() = 0; + virtual void editColors() = 0; + virtual void editAxes() = 0; + virtual void editScaling() = 0; + virtual void editFonts() = 0; + virtual void editConstants() = 0; + virtual void newFunction() = 0; + virtual void newParametric() = 0; + virtual void newPolar() = 0; + virtual void toggleShowSlider0() = 0; + virtual void toggleShowSlider1() = 0; + virtual void toggleShowSlider2() = 0; + virtual void toggleShowSlider3() = 0; + virtual void slotSave() = 0; + virtual void slotSaveas() = 0; + virtual void slotEditPlots() = 0; + virtual void slotPrint() = 0; + virtual void slotExport() = 0; + virtual void slotSettings() = 0; + virtual void slotNames() = 0; + virtual void slotCoord1() = 0; + virtual void slotCoord2() = 0; + virtual void slotCoord3() = 0; + virtual void getYValue() = 0; + virtual void findMinimumValue() = 0; + virtual void findMaximumValue() = 0; + virtual void graphArea() = 0; +}; + +#endif diff --git a/kmplot/kmplot/Makefile.am b/kmplot/kmplot/Makefile.am new file mode 100644 index 00000000..f5158dc9 --- /dev/null +++ b/kmplot/kmplot/Makefile.am @@ -0,0 +1,61 @@ +# set the include path for X, qt and KDE +INCLUDES= $(all_includes) + +# these are the headers for your project +noinst_HEADERS = kmplot.h kmplotprogress.h MainDlg.h + +METASOURCES = AUTO + +messages: rc.cpp + $(EXTRACTRC) *.ui >> rc.cpp + LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \ + if test -n "$$LIST"; then \ + $(XGETTEXT) $$LIST -o $(podir)/kmplot.pot; \ + fi +# messages: rc.cpp +# $(XGETTEXT) *.cpp -o $(podir)/kmplot.pot + + +######################################################################### +# APPLICATION SECTION +######################################################################### +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = kmplot + +# the application source, library search path, and link libraries +kmplot_SOURCES = main.cpp kmplot.cpp kmplotprogress.cpp kmplotIface.skel +kmplot_LDFLAGS = $(KDE_RPATH) $(all_libraries) +kmplot_LDADD = $(LIB_KPARTS) + +# this is where the desktop file will go +appmimedir = $(kde_mimedir)/application +appmime_DATA = x-kmplot.desktop + +# this is where the shell's XML-GUI resource file goes +shellrcdir = $(kde_datadir)/kmplot +shellrc_DATA = kmplot_shell.rc + + +######################################################################### +# KPART SECTION +######################################################################### +kde_module_LTLIBRARIES = libkmplotpart.la + +# the Part's source, library search path, and link libraries +libkmplotpart_la_SOURCES = FktDlgData.ui parser.cpp xparser.cpp diagr.cpp View.cpp MainDlg.cpp FktDlg.cpp kprinterdlg.cpp settings.kcfgc settingspagecolor.ui kconstanteditor.cpp qparametereditor.ui kparametereditor.cpp settingspagecoords.ui settingspagefonts.ui settingspagescaling.ui settingspageprecision.ui qeditparametric.ui keditparametric.cpp qeditpolar.ui keditpolar.cpp editfunctionpage.ui editderivativespage.ui editintegralpage.ui editfunction.cpp qeditconstant.ui qminmax.ui kminmax.cpp qconstanteditor.ui keditconstant.cpp kmplotio.cpp sliderwindow.ui ksliderwindow.cpp MainDlgIface.skel parseriface.skel Viewiface.skel coordsconfigdialog.cpp +libkmplotpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +libkmplotpart_la_LIBADD = $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) $(LIB_KDEPRINT) + +# this is where the desktop file will go +partdesktopdir = $(kde_servicesdir) +partdesktop_DATA = kmplot_part.desktop + +# this is where the part's XML-GUI resource file goes +partrcdir = $(kde_datadir)/kmplot +partrc_DATA = kmplot_part.rc kmplot_part_readonly.rc + +EXTRA_DIST = kmplot.desktop FktDlg.h MainDlg.cpp MainDlg.h View.h diagr.cpp diagr.h xparser.h parser.h kprinterdlg.h keditparametric.h keditpolar.h ksliderwindow.h keditconstant.h kconstanteditor.h kparametereditor.h kmplotio.h kminmax.h coordsconfigdialog.h + +xdg_apps_DATA = kmplot.desktop +kde_kcfg_DATA = kmplot.kcfg diff --git a/kmplot/kmplot/View.cpp b/kmplot/kmplot/View.cpp new file mode 100644 index 00000000..2df9647d --- /dev/null +++ b/kmplot/kmplot/View.cpp @@ -0,0 +1,2149 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +// Qt includes +#include <qbitmap.h> +#include <qcursor.h> +#include <qdatastream.h> +#include <qpicture.h> +#include <qslider.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +// KDE includes +#include <kaction.h> +#include <kapplication.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpopupmenu.h> +#include <kprogress.h> + +// local includes +#include "editfunction.h" +#include "keditparametric.h" +#include "kminmax.h" +#include "settings.h" +#include "ksliderwindow.h" +#include "View.h" +#include "View.moc" + +//minimum and maximum x range. Should always be accessible. +double View::xmin = 0; +double View::xmax = 0; + + +View::View(bool const r, bool &mo, KPopupMenu *p, QWidget* parent, const char* name ) : DCOPObject("View"), QWidget( parent, name , WStaticContents ), buffer( width(), height() ), m_popupmenu(p), m_modified(mo), m_readonly(r), m_dcop_client(KApplication::kApplication()->dcopClient()) +{ + csmode = csparam = -1; + cstype = 0; + areaDraw = false; + areaUfkt = 0; + areaPMode = 0; + areaMin = areaMax = 0.0; + w = h = 0; + s = 0.0; + fcx = 0; + fcy = 0; + csxpos = 0.0; + csypos = 0.0; + rootflg = false; + tlgx = tlgy = drskalx = drskaly = 0.0;; + stepWidth = 0.0; + ymin = 0.0;; + ymax = 0.0;; + m_printHeaderTable = false; + stop_calculating = false; + m_minmax = 0; + isDrawing = false; + m_popupmenushown = 0; + + m_parser = new XParser(mo); + init(); + csflg=0; + csmode=-1; + backgroundcolor = Settings::backgroundcolor(); + invertColor(backgroundcolor,inverted_backgroundcolor); + setBackgroundColor(backgroundcolor); + setMouseTracking(true); + rootflg = false; + for( int number = 0; number < SLIDER_COUNT; number++ ) + sliders[ number ] = 0; + updateSliders(); + m_popupmenushown = 0; + m_popupmenu->insertTitle( "",10); + zoom_mode = Z_Normal; + isDrawing=false; + areaDraw = false; +} + +void View::setMinMaxDlg(KMinMax *minmaxdlg) +{ + m_minmax = minmaxdlg; +} + +View::~View() +{ + delete m_parser; +} + +XParser* View::parser() +{ + return m_parser; +} + +void View::draw(QPaintDevice *dev, int form) +{ + int lx, ly; + float sf; + QRect rc; + QPainter DC; // our painter + DC.begin(dev); // start painting widget + rc=DC.viewport(); + w=rc.width(); + h=rc.height(); + + setPlotRange(); + setScaling(); + + if(form==0) // screen + { + ref=QPoint(120, 100); + lx=(int)((xmax-xmin)*100.*drskalx/tlgx); + ly=(int)((ymax-ymin)*100.*drskaly/tlgy); + DC.scale((float)h/(float)(ly+2*ref.y()), (float)h/(float)(ly+2*ref.y())); + if(DC.xForm(QPoint(lx+2*ref.x(), ly)).x() > DC.viewport().right()) + { + DC.resetXForm(); + DC.scale((float)w/(float)(lx+2*ref.x()), (float)w/(float)(lx+2*ref.x())); + } + wm=DC.worldMatrix(); + s=DC.xForm(QPoint(1000, 0)).x()/1000.; + dgr.Create( ref, lx, ly, xmin, xmax, ymin, ymax ); + } + else if(form==1) // printer + { + sf=72./254.; // 72dpi + ref=QPoint(100, 100); + lx=(int)((xmax-xmin)*100.*drskalx/tlgx); + ly=(int)((ymax-ymin)*100.*drskaly/tlgy); + DC.scale(sf, sf); + s=1.; + m_printHeaderTable = ( ( KPrinter* ) dev )->option( "app-kmplot-printtable" ) != "-1"; + drawHeaderTable( &DC ); + dgr.Create( ref, lx, ly, xmin, xmax, ymin, ymax ); + if ( ( (KPrinter* )dev )->option( "app-kmplot-printbackground" ) == "-1" ) + DC.fillRect( dgr.GetFrame(), backgroundcolor); //draw a colored background + //DC.end(); + //((QPixmap *)dev)->fill(QColor("#FF00FF")); + //DC.begin(dev); + } + else if(form==2) // svg + { + ref=QPoint(0, 0); + lx=(int)((xmax-xmin)*100.*drskalx/tlgx); + ly=(int)((ymax-ymin)*100.*drskaly/tlgy); + dgr.Create( ref, lx, ly, xmin, xmax, ymin, ymax ); + DC.translate(-dgr.GetFrame().left(), -dgr.GetFrame().top()); + s=1.; + } + else if(form==3) // bmp, png + { + sf=180./254.; // 180dpi + ref=QPoint(0, 0); + lx=(int)((xmax-xmin)*100.*drskalx/tlgx); + ly=(int)((ymax-ymin)*100.*drskaly/tlgy); + dgr.Create( ref, lx, ly, xmin, xmax, ymin, ymax ); + DC.end(); + ((QPixmap *)dev)->resize((int)(dgr.GetFrame().width()*sf), (int)(dgr.GetFrame().height()*sf)); + ((QPixmap *)dev)->fill(backgroundcolor); + DC.begin(dev); + DC.translate(-dgr.GetFrame().left()*sf, -dgr.GetFrame().top()*sf); + DC.scale(sf, sf); + s=1.; + } + + dgr.borderThickness=(uint)(4*s); + dgr.axesLineWidth = (uint)( Settings::axesLineWidth()*s ); + dgr.gridLineWidth = (uint)( Settings::gridLineWidth()*s ); + dgr.ticWidth = (uint)( Settings::ticWidth()*s ); + dgr.ticLength = (uint)( Settings::ticLength() ); + dgr.axesColor = Settings::axesColor().rgb(); + dgr.gridColor=Settings::gridColor().rgb(); + dgr.Skal( tlgx, tlgy ); + + if ( form!=0 && areaDraw) + { + areaUnderGraph(areaUfkt, areaPMode, areaMin,areaMax, areaParameter, &DC); + areaDraw = false; + if (stop_calculating) + return; + } + + dgr.Plot(&DC); + PlotArea=dgr.GetPlotArea(); + area=DC.xForm(PlotArea); + hline.resize(area.width(), 1); + vline.resize(1, area.height()); + stepWidth=Settings::stepWidth(); + + isDrawing=true; + setCursor(Qt::WaitCursor ); + stop_calculating = false; + for(QValueVector<Ufkt>::iterator ufkt=m_parser->ufkt.begin(); ufkt!=m_parser->ufkt.end() && !stop_calculating; ++ufkt) + if ( !ufkt->fname.isEmpty() ) + plotfkt(ufkt, &DC); + + isDrawing=false; + restoreCursor(); + csflg=0; + DC.end(); // painting done +} + + +void View::plotfkt(Ufkt *ufkt, QPainter *pDC) +{ + char p_mode; + int iy, k, ke, mflg; + double x, y, dmin, dmax; + QPoint p1, p2; + QPen pen; + pen.setCapStyle(Qt::RoundCap); + iy=0; + y=0.0; + + char const fktmode=ufkt->fstr[0].latin1(); + if(fktmode=='y') return ; + + dmin=ufkt->dmin; + dmax=ufkt->dmax; + + if(!ufkt->usecustomxmin) + { + if(fktmode=='r') + dmin=0.; + else if ( fktmode == 'x' ) + dmin = -M_PI; + else + dmin = xmin; + } + if(!ufkt->usecustomxmax) + { + if(fktmode=='r') + dmax=2*M_PI; + else if ( fktmode == 'x' ) + dmax = M_PI; + else + dmax = xmax; + } + double dx; + if(fktmode=='r') + if ( Settings::useRelativeStepWidth() ) + dx=stepWidth*0.05/(dmax-dmin); + else + dx=stepWidth; + else + if ( Settings::useRelativeStepWidth() ) + dx=stepWidth*(dmax-dmin)/area.width(); + else + dx=stepWidth; + + if(fktmode=='x') + iy = m_parser->ixValue(ufkt->id)+1; + p_mode=0; + pen.setWidth((int)(ufkt->linewidth*s) ); + pen.setColor(ufkt->color); + pDC->setPen(pen); + + while(1) + { + k=0; + ke=ufkt->parameters.count(); + do + { + kdDebug() << "drawing " << ufkt->id << endl; + if ( p_mode == 3 && stop_calculating) + break; + if( ufkt->use_slider == -1 ) + { + if ( !ufkt->parameters.isEmpty() ) + ufkt->setParameter( ufkt->parameters[k].value ); + } + else + { + if ( KSliderWindow * sw = sliders[ ufkt->use_slider ] ) + ufkt->setParameter( sw->slider->value() ); + } + + mflg=2; + if ( p_mode == 3) + { + if ( ufkt->integral_use_precision ) + if ( Settings::useRelativeStepWidth() ) + dx = ufkt->integral_precision*(dmax-dmin)/area.width(); + else + dx = ufkt->integral_precision; + startProgressBar((int)double((dmax-dmin)/dx)/2); + x = ufkt->oldx = ufkt->startx; //the initial x-point + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + paintEvent(0); + } + else + x=dmin; + bool forward_direction; + + if (dmin<0 && dmax<0) + forward_direction = false; + else + forward_direction = true; + + if ( p_mode != 0 || ufkt->f_mode) // if not the function is hidden + while ((x>=dmin && x<=dmax) || (p_mode == 3 && x>=dmin && !forward_direction) || (p_mode == 3 && x<=dmax && forward_direction)) + { + if ( p_mode == 3 && stop_calculating) + { + p_mode=1; + x=dmax+1; + continue; + } + switch(p_mode) + { + case 0: + y=m_parser->fkt(ufkt, x); + break; + case 1: + y=m_parser->a1fkt(ufkt, x); + break; + case 2: + y=m_parser->a2fkt(ufkt, x); + break; + case 3: + { + y = m_parser->euler_method(x, ufkt); + if ( int(x*100)%2==0) + { + KApplication::kApplication()->processEvents(); //makes the program usable when drawing a complicated integral function + increaseProgressBar(); + } + break; + } + } + + if(fktmode=='r') + { + p2.setX(dgr.Transx(y*cos(x))); + p2.setY(dgr.Transy(y*sin(x))); + } + else if(fktmode=='x') + { + p2.setX(dgr.Transx(y)); + p2.setY(dgr.Transy(m_parser->fkt(iy, x))); + } + else + { + p2.setX(dgr.Transx(x)); + p2.setY(dgr.Transy(y)); + } + + if ( dgr.xclipflg || dgr.yclipflg ) + { + //if(mflg>=1) + p1=p2; + /*else + { + pDC->drawLine(p1, p2); + p1=p2; + mflg=1; + }*/ + } + else + { + if(mflg<=1) + pDC->drawLine(p1, p2); + p1=p2; + mflg=0; + } + + if (p_mode==3) + { + if ( forward_direction) + { + x=x+dx; + if (x>dmax && p_mode== 3) + { + forward_direction = false; + x = ufkt->oldx = ufkt->startx; + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + paintEvent(0); + mflg=2; + } + } + else + x=x-dx; // go backwards + } + else + x=x+dx; + } + } + while(++k<ke); + + if(ufkt->f1_mode==1 && p_mode< 1) //draw the 1st derivative + { + p_mode=1; + pen.setWidth((int)(ufkt->f1_linewidth*s) ); + pen.setColor(ufkt->f1_color); + pDC->setPen(pen); + } + else if(ufkt->f2_mode==1 && p_mode< 2) //draw the 2nd derivative + { + p_mode=2; + pen.setWidth((int)(ufkt->f2_linewidth*s) ); + pen.setColor(ufkt->f2_color); + pDC->setPen(pen); + } + else if( ufkt->integral_mode==1 && p_mode< 3) //draw the integral + { + p_mode=3; + pen.setWidth((int)(ufkt->integral_linewidth*s) ); + pen.setColor(ufkt->integral_color); + pDC->setPen(pen); + } + else break; //otherwise stop + } + if ( stopProgressBar() ) + if( stop_calculating) + KMessageBox::error(this,i18n("The drawing was cancelled by the user.")); +} + +void View::drawHeaderTable(QPainter *pDC) +{ + QString alx, aly, atx, aty, dfx, dfy; + + if( m_printHeaderTable ) + { + pDC->translate(250., 150.); + pDC->setPen(QPen(black, (int)(5.*s))); + pDC->setFont(QFont( Settings::headerTableFont(), 30) ); + puts( Settings::headerTableFont().latin1() ); + QString minStr = Settings::xMin(); + QString maxStr = Settings::xMax(); + getMinMax( Settings::xRange(), minStr, maxStr); + alx="[ "+minStr+" | "+maxStr+" ]"; + minStr = Settings::yMin(); + maxStr = Settings::yMax(); + getMinMax( Settings::yRange(), minStr, maxStr); + aly="[ "+minStr+" | "+maxStr+" ]"; + setpi(&alx); + setpi(&aly); + atx="1E = "+tlgxstr; + setpi(&atx); + aty="1E = "+tlgystr; + setpi(&aty); + dfx="1E = "+drskalxstr+" cm"; + setpi(&dfx); + dfy="1E = "+drskalystr+" cm"; + setpi(&dfy); + + pDC->drawRect(0, 0, 1500, 230); + pDC->Lineh(0, 100, 1500); + pDC->Linev(300, 0, 230); + pDC->Linev(700, 0, 230); + pDC->Linev(1100, 0, 230); + + pDC->drawText(0, 0, 300, 100, AlignCenter, i18n("Parameters:")); + pDC->drawText(300, 0, 400, 100, AlignCenter, i18n("Plotting Area")); + pDC->drawText(700, 0, 400, 100, AlignCenter, i18n("Axes Division")); + pDC->drawText(1100, 0, 400, 100, AlignCenter, i18n("Printing Format")); + pDC->drawText(0, 100, 300, 65, AlignCenter, i18n("x-Axis:")); + pDC->drawText(0, 165, 300, 65, AlignCenter, i18n("y-Axis:")); + pDC->drawText(300, 100, 400, 65, AlignCenter, alx); + pDC->drawText(300, 165, 400, 65, AlignCenter, aly); + pDC->drawText(700, 100, 400, 65, AlignCenter, atx); + pDC->drawText(700, 165, 400, 65, AlignCenter, aty); + pDC->drawText(1100, 100, 400, 65, AlignCenter, dfx); + pDC->drawText(1100, 165, 400, 65, AlignCenter, dfy); + + pDC->drawText(0, 300, i18n("Functions:")); + pDC->Lineh(0, 320, 700); + int ypos = 380; + //for(uint ix=0; ix<m_parser->countFunctions() && !stop_calculating; ++ix) + for(QValueVector<Ufkt>::iterator it=m_parser->ufkt.begin(); it!=m_parser->ufkt.end() && !stop_calculating; ++it) + { + pDC->drawText(100, ypos, it->fstr); + ypos+=60; + } + pDC->translate(-60., ypos+100.); + } + else pDC->translate(150., 150.); +} + + +void View::getMinMax( int koord, QString &mini, QString &maxi ) +{ + switch(koord) + { + case 0: + mini="-8.0"; + maxi="8.0"; + break; + case 1: + mini="-5.0"; + maxi="5.0"; + break; + case 2: + mini="0.0"; + maxi="16.0"; + break; + case 3: + mini="0.0"; + maxi="10.0"; + } +} + + +void View::setpi(QString *s) +{ + int i; + QChar c(960); + + while((i=s->find('p')) != -1) s->replace(i, 2, &c, 1); +} + + +bool View::root(double *x0, Ufkt *it) +{ + if(rootflg) + return false; + double yn; + double x=csxpos; + double y=fabs(csypos); + double dx=0.1; + while(1) + { + if((yn=fabs(m_parser->fkt(it, x-dx))) < y) + { + x-=dx; + y=yn; + } + else if((yn=fabs(m_parser->fkt(it, x+dx))) < y) + { + x+=dx; + y=yn; + } + else + dx/=10.; + printf("x=%g, dx=%g, y=%g\n", x, dx, y); + if(y<1e-8) + { + *x0=x; + return true; + } + if(fabs(dx)<1e-8) + return false; + if(x<xmin || x>xmax) + return false; + } +} + +void View::paintEvent(QPaintEvent *) +{ + QPainter p; + p.begin(this); + bitBlt( this, 0, 0, &buffer, 0, 0, width(), height() ); + p.end(); +} + +void View::resizeEvent(QResizeEvent *) +{ + if (isDrawing) //stop drawing integrals + { + stop_calculating = true; //stop drawing + return; + } + buffer.resize(size() ); + drawPlot(); +} + +void View::drawPlot() +{ + if( m_minmax->isShown() ) + m_minmax->updateFunctions(); + buffer.fill(backgroundcolor); + draw(&buffer, 0); + QPainter p; + p.begin(this); + bitBlt( this, 0, 0, &buffer, 0, 0, width(), height() ); + p.end(); +} + +void View::mouseMoveEvent(QMouseEvent *e) +{ + if ( isDrawing) + return; + if (zoom_mode==4 && e->stateAfter() != Qt::NoButton) + { + QPainter p; + p.begin(this); + bitBlt( this, 0, 0, &buffer, 0, 0, width(), height() ); + p.end(); + + QPainter painter(this); + QPen pen(Qt::white, 1, Qt::DotLine); + painter.setRasterOp (Qt::XorROP); + painter.setPen(pen); + painter.setBackgroundMode (QPainter::OpaqueMode); + painter.setBackgroundColor (Qt::blue); + + painter.drawRect(rectangle_point.x(), rectangle_point.y(), e->pos().x()-rectangle_point.x(), e->pos().y()-rectangle_point.y()); + return; + + } + if ( zoom_mode!=0) + return; + if( m_popupmenushown>0 && !m_popupmenu->isShown() ) + { + if ( m_popupmenushown==1) + csmode=-1; + m_popupmenushown = 0; + return; + } + if(csflg==1) // Fadenkreuz l�chen + { + bitBlt(this, area.left(), fcy, &hline, 0, 0, area.width(), 1); + bitBlt(this, fcx, area.top(), &vline, 0, 0, 1, area.height()); + csflg=0; + } + + if(area.contains(e->pos()) || (e->button()==Qt::LeftButton && e->state()==Qt::LeftButton && csxpos>xmin && csxpos<xmax)) + { + QPoint ptd, ptl; + QPainter DC; + bool out_of_bounds = false; + + DC.begin(this); + DC.setWindow(0, 0, w, h); + DC.setWorldMatrix(wm); + ptl=DC.xFormDev(e->pos()); + Ufkt *it = 0; + if( csmode >= 0 && csmode <= (int)m_parser->countFunctions() ) + { + int const ix = m_parser->ixValue(csmode); + if (ix!=-1 && ((!m_parser->ufkt[ix].usecustomxmin) || (m_parser->ufkt[ix].usecustomxmin && csxpos>m_parser->ufkt[ix].dmin)) && ((!m_parser->ufkt[ix].usecustomxmax)||(m_parser->ufkt[ix].usecustomxmax && csxpos<m_parser->ufkt[ix].dmax)) ) + { + it = &m_parser->ufkt[ix]; + if( it->use_slider == -1 ) + { + if( it->parameters.isEmpty() ) + it->setParameter( it->parameters[csparam].value ); + } + else + it->setParameter(sliders[ it->use_slider ]->slider->value() ); + if ( cstype == 0) + ptl.setY(dgr.Transy(csypos=m_parser->fkt( it, csxpos=dgr.Transx(ptl.x())))); + else if ( cstype == 1) + ptl.setY(dgr.Transy(csypos=m_parser->a1fkt( it, csxpos=dgr.Transx(ptl.x()) ))); + else if ( cstype == 2) + ptl.setY(dgr.Transy(csypos=m_parser->a2fkt( it, csxpos=dgr.Transx(ptl.x())))); + + if ( csypos<ymin || csypos>ymax) //the ypoint is not visible + out_of_bounds = true; + else if(fabs(dgr.Transy(ptl.y())) < (xmax-xmin)/80) + { + double x0; + if(root(&x0, it)) + { + QString str=" "; + str+=i18n("root"); + setStatusBar(str+QString().sprintf(": x0= %+.5f", x0), 3); + rootflg=true; + } + } + else + { + setStatusBar("", 3); + rootflg=false; + } + } + else + { + csxpos=dgr.Transx(ptl.x()); + csypos=dgr.Transy(ptl.y()); + csflg = 1; + } + } + else + { + csxpos=dgr.Transx(ptl.x()); + csypos=dgr.Transy(ptl.y()); + } + ptd=DC.xForm(ptl); + DC.end(); + QString sx, sy; + if (out_of_bounds) + { + sx = sy = ""; + } + else + { + sx.sprintf(" x= %+.2f", (float)dgr.Transx(ptl.x()));//csxpos); + sy.sprintf(" y= %+.2f", csypos); + } + if(csflg==0) // Hintergrund speichern + { + bitBlt(&hline, 0, 0, this, area.left(), fcy=ptd.y(), area.width(), 1); + bitBlt(&vline, 0, 0, this, fcx=ptd.x(), area.top(), 1, area.height()); + // Fadenkreuz zeichnen + QPen pen; + if ( csmode == -1) + pen.setColor(inverted_backgroundcolor); + else + { + if ( csmode == -1) + pen.setColor(inverted_backgroundcolor); + else + { + switch (cstype) + { + case 0: + pen.setColor( it->color); + break; + case 1: + pen.setColor( it->f1_color); + break; + case 2: + pen.setColor( it->f2_color); + break; + default: + pen.setColor(inverted_backgroundcolor); + } + if ( pen.color() == backgroundcolor) // if the "Fadenkreuz" has the same color as the background, the "Fadenkreuz" will have the inverted color of background so you can see it easier + pen.setColor(inverted_backgroundcolor); + } + } + DC.begin(this); + DC.setPen(pen); + DC.Lineh(area.left(), fcy, area.right()); + DC.Linev(fcx, area.bottom(), area.top()); + DC.end(); + } + csflg=1; + setCursor(Qt::blankCursor); + setStatusBar(sx, 1); + setStatusBar(sy, 2); + } + else + { + setCursor(arrowCursor); + setStatusBar("", 1); + setStatusBar("", 2); + } + +} + + +void View::mousePressEvent(QMouseEvent *e) +{ + if ( m_popupmenushown>0) + return; + + if (isDrawing) + { + stop_calculating = true; //stop drawing + return; + } + + if ( zoom_mode==Z_Rectangular ) //rectangle zoom + { + zoom_mode=Z_Center; + rectangle_point = e->pos(); + return; + } + else if ( zoom_mode==Z_ZoomIn ) //zoom in + { + QPainter DC; + DC.begin(this); + DC.setWindow(0, 0, w, h); + DC.setWorldMatrix(wm); + double real = dgr.Transx(DC.xFormDev(e->pos()).x()); + + double const diffx = (xmax-xmin)*(double)Settings::zoomInStep()/100; + double const diffy = (ymax-ymin)*(double)Settings::zoomInStep()/100; + + if ( diffx < 0.00001 || diffy < 0.00001) + return; + + Settings::setXMin( Parser::number( real-double(diffx) ) ); + Settings::setXMax( Parser::number( real+double(diffx) ) ); + + real = dgr.Transy(DC.xFormDev(e->pos()).y()); + Settings::setYMin( Parser::number( real-double(diffy) ) ); + Settings::setYMax( Parser::number( real+double(diffy) ) ); + + Settings::setXRange(4); //custom x-range + Settings::setYRange(4); //custom y-range + drawPlot(); //update all graphs + return; + + } + else if ( zoom_mode==3 ) //zoom out + { + QPainter DC; + DC.begin(this); + DC.setWindow(0, 0, w, h); + DC.setWorldMatrix(wm); + double real = dgr.Transx(DC.xFormDev(e->pos()).x()); + + double const diffx = (xmax-xmin)*(((double)Settings::zoomOutStep()/100) +1); + double const diffy = (ymax-ymin)*(((double)Settings::zoomOutStep()/100) +1); + + if ( diffx > 1000000 || diffy > 1000000) + return; + + Settings::setXMin( Parser::number( real-double(diffx) ) ); + Settings::setXMax( Parser::number( real+double(diffx) ) ); + + real = dgr.Transy(DC.xFormDev(e->pos()).y()); + Settings::setYMin( Parser::number( real-double(diffy) ) ); + Settings::setYMax( Parser::number( real+double(diffy) ) ); + + Settings::setXRange(4); //custom x-range + Settings::setYRange(4); //custom y-range + drawPlot(); //update all graphs + return; + + } + else if ( zoom_mode==5 ) //center + { + QPainter DC; + DC.begin(this); + DC.setWindow(0, 0, w, h); + DC.setWorldMatrix(wm); + double real = dgr.Transx(DC.xFormDev(e->pos()).x()); + + double const diffx = (xmax-xmin)/2; + double const diffy = (ymax-ymin)/2; + + Settings::setXMin( Parser::number( real-double(diffx) ) ); + Settings::setXMax( Parser::number( real+double(diffx) ) ); + + real = dgr.Transy(DC.xFormDev(e->pos()).y()); + Settings::setYMin( Parser::number( real-double(diffy) ) ); + Settings::setYMax( Parser::number( real+double(diffy) ) ); + + Settings::setXRange(4); //custom x-range + Settings::setYRange(4); //custom y-range + drawPlot(); //update all graphs + return; + + } + double const g=tlgy*double(xmax-xmin)/(2*double(ymax-ymin)); + if( !m_readonly && e->button()==RightButton) //clicking with the right mouse button + { + char function_type; + for( QValueVector<Ufkt>::iterator it = m_parser->ufkt.begin(); it != m_parser->ufkt.end(); ++it) + { + function_type = it->fstr[0].latin1(); + if ( function_type=='y' || function_type=='r' || it->fname.isEmpty()) continue; + if (!(((!it->usecustomxmin) || (it->usecustomxmin && csxpos>it->dmin)) && ((!it->usecustomxmax)||(it->usecustomxmax && csxpos<it->dmax)) )) + continue; + kdDebug() << "it:" << it->fstr << endl; + int k=0; + int const ke=it->parameters.count(); + do + { + if( it->use_slider == -1 ) + { + if ( !it->parameters.isEmpty()) + it->setParameter(it->parameters[k].value); + } + else + { + if ( KSliderWindow * sw = sliders[ it->use_slider ] ) + it->setParameter( sw->slider->value() ); + } + + if ( function_type=='x' && fabs(csxpos-m_parser->fkt(it, csxpos))< g && it->fstr.contains('t')==1) //parametric plot + { + QValueVector<Ufkt>::iterator ufkt_y = it+1; + if ( fabs(csypos-m_parser->fkt(ufkt_y, csxpos)<g) && ufkt_y->fstr.contains('t')==1) + { + if ( csmode == -1) + { + csmode=it->id; + cstype=0; + csparam = k; + m_popupmenushown = 1; + } + else + m_popupmenushown = 2; + QString y_name( ufkt_y->fstr ); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-1),false); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-2),false); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-3),false); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-4),false); + m_popupmenu->changeTitle(10,ufkt_y->fstr+";"+y_name); + m_popupmenu->exec(QCursor::pos()); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-1),true); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-2),true); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-3),true); + m_popupmenu->setItemEnabled(m_popupmenu->idAt(m_popupmenu->count()-4),true); + return; + } + } + else if( fabs(csypos-m_parser->fkt(it, csxpos))< g && it->f_mode) + { + if ( csmode == -1) + { + csmode=it->id; + cstype=0; + csparam = k; + m_popupmenushown = 1; + } + else + m_popupmenushown = 2; + m_popupmenu->changeTitle(10, it->fstr); + m_popupmenu->exec(QCursor::pos()); + return; + } + else if(fabs(csypos-m_parser->a1fkt( it, csxpos))< g && it->f1_mode) + { + if ( csmode == -1) + { + csmode=it->id; + cstype=1; + csparam = k; + m_popupmenushown = 1; + } + else + m_popupmenushown = 2; + QString function = it->fstr; + function = function.left(function.find('(')) + '\''; + m_popupmenu->changeTitle(10, function); + m_popupmenu->exec(QCursor::pos()); + return; + } + else if(fabs(csypos-m_parser->a2fkt(it, csxpos))< g && it->f2_mode) + { + if ( csmode == -1) + { + csmode=it->id; + cstype=2; + csparam = k; + m_popupmenushown = 1; + } + else + m_popupmenushown = 2; + QString function = it->fstr; + function = function.left(function.find('(')) + "\'\'"; + m_popupmenu->changeTitle(10, function); + m_popupmenu->exec(QCursor::pos()); + return; + } + } + while(++k<ke); + } + return; + } + if(e->button()!=LeftButton) return ; + if(csmode>=0) //disable trace mode if trace mode is enable + { + csmode=-1; + setStatusBar("",3); + setStatusBar("",4); + mouseMoveEvent(e); + return ; + } + for( QValueVector<Ufkt>::iterator it = m_parser->ufkt.begin(); it != m_parser->ufkt.end(); ++it) + { + if (it->fname.isEmpty() ) + continue; + switch(it->fstr[0].latin1()) + { + case 'x': case 'y': case 'r': continue; // Not possible to catch + } + if (!(((!it->usecustomxmin) || (it->usecustomxmin && csxpos>it->dmin)) && ((!it->usecustomxmax)||(it->usecustomxmax && csxpos<it->dmax)) )) + continue; + int k=0; + int const ke=it->parameters.count(); + do + { + if( it->use_slider == -1 ) + { + if ( !it->parameters.isEmpty() ) + it->setParameter( it->parameters[k].value ); + } + else + { + if ( KSliderWindow * sw = sliders[ it->use_slider ] ) + it->setParameter( sw->slider->value() ); + } + if(fabs(csypos-m_parser->fkt(it, csxpos))< g && it->f_mode) + { + csmode=it->id; + cstype=0; + csparam = k; + m_minmax->selectItem(); + setStatusBar(it->fstr,4); + mouseMoveEvent(e); + return; + } + if(fabs(csypos-m_parser->a1fkt( it, csxpos))< g && it->f1_mode) + { + csmode=it->id; + cstype=1; + csparam = k; + m_minmax->selectItem(); + QString function = it->fstr; + function = function.left(function.find('(')) + '\''; + setStatusBar(function,4); + mouseMoveEvent(e); + return; + } + if(fabs(csypos-m_parser->a2fkt(it, csxpos))< g && it->f2_mode) + { + csmode=it->id; + cstype=2; + csparam = k; + m_minmax->selectItem(); + QString function = it->fstr; + function = function.left(function.find('(')) + "\'\'"; + setStatusBar(function,4); + mouseMoveEvent(e); + return; + } + } + while(++k<ke); + } + + csmode=-1; +} + + +void View::mouseReleaseEvent ( QMouseEvent * e ) +{ + if ( zoom_mode == Z_Center ) + { + zoom_mode = Z_Rectangular; + if( (e->pos().x() - rectangle_point.x() >= -2) && (e->pos().x() - rectangle_point.x() <= 2) || + (e->pos().y() - rectangle_point.y() >= -2) && (e->pos().y() - rectangle_point.y() <= 2) ) + { + update(); + return; + } + QPainter DC; + DC.begin(this); + bitBlt( this, 0, 0, &buffer, 0, 0, width(), height() ); + DC.setWindow(0, 0, w, h); + DC.setWorldMatrix(wm); + + QPoint p=DC.xFormDev(e->pos()); + double real1x = dgr.Transx(p.x() ) ; + double real1y = dgr.Transy(p.y() ) ; + p=DC.xFormDev(rectangle_point); + double real2x = dgr.Transx(p.x() ) ; + double real2y = dgr.Transy(p.y() ) ; + + + if ( real1x>xmax || real2x>xmax || real1x<xmin || real2x<xmin || + real1y>ymax || real2y>ymax || real1y<ymin || real2y<ymin ) + return; //out of bounds + + //setting new x-boundaries + if( real1x < real2x ) + { + if( real2x - real1x < 0.00001) + return; + Settings::setXMin( Parser::number( real1x ) ); + Settings::setXMax( Parser::number( real2x ) ); + } + else + { + if (real1x - real2x < 0.00001) + return; + Settings::setXMin( Parser::number( real2x ) ); + Settings::setXMax( Parser::number( real1x ) ); + } + //setting new y-boundaries + if( real1y < real2y ) + { + if( real2y - real1y < 0.00001) + return; + Settings::setYMin( Parser::number( real1y ) ); + Settings::setYMax( Parser::number( real2y ) ); + } + else + { + if( real1y - real2y < 0.00001) + return; + Settings::setYMin( Parser::number( real2y ) ); + Settings::setYMax( Parser::number( real1y ) ); + } + Settings::setXRange(4); //custom x-range + Settings::setYRange(4); //custom y-range + drawPlot(); //update all graphs + } +} + +void View::coordToMinMax( const int koord, const QString &minStr, const QString &maxStr, + double &min, double &max ) +{ + switch ( koord ) + { + case 0: + min = -8.0; + max = 8.0; + break; + case 1: + min = -5.0; + max = 5.0; + break; + case 2: + min = 0.0; + max = 16.0; + break; + case 3: + min = 0.0; + max = 10.0; + break; + case 4: + min = m_parser->eval( minStr ); + max = m_parser->eval( maxStr ); + } +} + +void View::setPlotRange() +{ + coordToMinMax( Settings::xRange(), Settings::xMin(), Settings::xMax(), xmin, xmax ); + coordToMinMax( Settings::yRange(), Settings::yMin(), Settings::yMax(), ymin, ymax ); +} + +void View::setScaling() +{ + QString units[ 9 ] = { "10", "5", "2", "1", "0.5", "pi/2", "pi/3", "pi/4",i18n("automatic") }; + + if( Settings::xScaling() == 8) //automatic x-scaling + { + tlgx = double(xmax-xmin)/16; + tlgxstr = units[ Settings::xScaling() ]; + } + else + { + tlgxstr = units[ Settings::xScaling() ]; + tlgx = m_parser->eval( tlgxstr ); + } + + if( Settings::yScaling() == 8) //automatic y-scaling + { + tlgy = double(ymax-ymin)/16; + tlgystr = units[ Settings::yScaling() ]; + } + else + { + tlgystr = units[ Settings::yScaling() ]; + tlgy = m_parser->eval( tlgystr ); + } + + drskalxstr = units[ Settings::xPrinting() ]; + drskalx = m_parser->eval( drskalxstr ); + drskalystr = units[ Settings::yPrinting() ]; + drskaly = m_parser->eval( drskalystr ); +} + +void View::getSettings() +{ + m_parser->setAngleMode( Settings::anglemode() ); + m_parser->linewidth0 = Settings::gridLineWidth(); + + backgroundcolor = Settings::backgroundcolor(); + invertColor(backgroundcolor,inverted_backgroundcolor); + setBackgroundColor(backgroundcolor); +} + +void View::init() +{ + getSettings(); + QValueVector<Ufkt>::iterator it = m_parser->ufkt.begin(); + it->fname=""; + while ( m_parser->ufkt.count() > 1) + m_parser->Parser::delfkt( &m_parser->ufkt.last() ); +} + + +void View::stopDrawing() +{ + if (isDrawing) + stop_calculating = true; +} + +void View::findMinMaxValue(Ufkt *ufkt, char p_mode, bool minimum, double &dmin, double &dmax, const QString &str_parameter) +{ + double x, y = 0; + double result_x = 0; + double result_y = 0; + bool start = true; + + // TODO: parameter sliders + if ( !ufkt->parameters.isEmpty() ) + { + for ( QValueList<ParameterValueItem>::Iterator it = ufkt->parameters.begin(); it != ufkt->parameters.end(); ++it ) + { + if ( (*it).expression == str_parameter) + { + ufkt->setParameter( (*it).value ); + break; + } + } + } + + isDrawing=true; + setCursor(Qt::WaitCursor ); + + double dx; + if ( p_mode == 3) + { + stop_calculating = false; + if ( ufkt->integral_use_precision ) + if ( ufkt->integral_use_precision ) + dx = ufkt->integral_precision*(dmax-dmin)/area.width(); + else + dx = ufkt->integral_precision; + else + if ( ufkt->integral_use_precision ) + dx = stepWidth*(dmax-dmin)/area.width(); + else + dx = stepWidth; + startProgressBar((int)double((dmax-dmin)/dx)/2); + x = ufkt->oldx = ufkt->startx; //the initial x-point + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + paintEvent(0); + } + else + { + dx = stepWidth*(dmax-dmin)/area.width(); + x=dmin; + } + + bool forward_direction; + if (dmin<0 && dmax<0) + forward_direction = false; + else + forward_direction = true; + while ((x>=dmin && x<=dmax) || (p_mode == 3 && x>=dmin && !forward_direction) || (p_mode == 3 && x<=dmax && forward_direction)) + { + if ( p_mode == 3 && stop_calculating) + { + p_mode = 1; + x=dmax+1; + continue; + } + switch(p_mode) + { + case 0: + y=m_parser->fkt(ufkt, x); + break; + + case 1: + { + y=m_parser->a1fkt( ufkt, x); + break; + } + case 2: + { + y=m_parser->a2fkt(ufkt, x); + break; + } + case 3: + { + y = m_parser->euler_method(x, ufkt); + if ( int(x*100)%2==0) + { + KApplication::kApplication()->processEvents(); //makes the program usable when drawing a complicated integral function + increaseProgressBar(); + } + break; + } + } + if ( !isnan(x) && !isnan(y) ) + { + kdDebug() << "x " << x << endl; + kdDebug() << "y " << y << endl; + if (x>=dmin && x<=dmax) + { + if ( start) + { + result_x = x; + result_y = y; + start=false; + } + else if ( minimum &&y <=result_y) + { + result_x = x; + result_y = y; + } + else if ( !minimum && y >=result_y) + { + result_x = x; + result_y = y; + } + } + } + if (p_mode==3) + { + if ( forward_direction) + { + x=x+dx; + if (x>dmax && p_mode== 3) + { + forward_direction = false; + x = ufkt->oldx = ufkt->startx; + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + paintEvent(0); + } + } + else + x=x-dx; // go backwards + } + else + x=x+dx; + } + stopProgressBar(); + isDrawing=false; + restoreCursor(); + + dmin = int(result_x*1000)/double(1000); + dmax = int(result_y*1000)/double(1000); + + switch (p_mode) + { + case 0: + dmax=m_parser->fkt(ufkt, dmin); + break; + case 1: + dmax=m_parser->a1fkt(ufkt, dmin); + break; + case 2: + dmax=m_parser->a2fkt(ufkt, dmin); + break; + } +} + +void View::getYValue(Ufkt *ufkt, char p_mode, double x, double &y, const QString &str_parameter) +{ + // TODO: parameter sliders + if ( !ufkt->parameters.isEmpty() ) + { + for ( QValueList<ParameterValueItem>::Iterator it = ufkt->parameters.begin(); it != ufkt->parameters.end(); ++it ) + { + if ( (*it).expression == str_parameter) + { + ufkt->setParameter((*it).value); + break; + } + } + } + + switch (p_mode) + { + case 0: + y= m_parser->fkt(ufkt, x); + break; + case 1: + y=m_parser->a1fkt( ufkt, x); + break; + case 2: + y=m_parser->a2fkt( ufkt, x); + break; + case 3: + double dmin = ufkt->dmin; + double dmax = ufkt->dmax; + const double target = x; //this is the x-value the user had chosen + bool forward_direction; + if ( target>=0) + forward_direction = true; + else + forward_direction = false; + + if(dmin==dmax) //no special plot range is specified. Use the screen border instead. + { + dmin=xmin; + dmax=xmax; + } + + double dx; + if ( ufkt->integral_use_precision ) + dx = ufkt->integral_precision*(dmax-dmin)/area.width(); + else + dx=stepWidth*(dmax-dmin)/area.width(); + + stop_calculating = false; + isDrawing=true; + setCursor(Qt::WaitCursor ); + bool target_found=false; + startProgressBar((int) double((dmax-dmin)/dx)/2); + x = ufkt->oldx = ufkt->startx; //the initial x-point + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + paintEvent(0); + while (x>=dmin && !stop_calculating && !target_found) + { + y = m_parser->euler_method( x, ufkt ); + if ( int(x*100)%2==0) + { + KApplication::kApplication()->processEvents(); //makes the program usable when drawing a complicated integral function + increaseProgressBar(); + } + + if ( (x+dx > target && forward_direction) || ( x+dx < target && !forward_direction)) //right x-value is found + target_found = true; + + + + if (forward_direction) + { + x=x+dx; + if (x>dmax) + { + forward_direction = false; + x = ufkt->oldx = ufkt->startx; + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + paintEvent(0); + } + } + else + x=x-dx; // go backwards + } + stopProgressBar(); + isDrawing=false; + restoreCursor(); + break; + } +} + +void View::keyPressEvent( QKeyEvent * e) +{ + if ( zoom_mode != Z_Normal && e->key() == Qt::Key_Escape ) + { + resetZoom(); + return; + } + if ( zoom_mode == Z_Center) //drawing a rectangle + { + zoom_mode = Z_Rectangular; + update(); + return; + } + + if (isDrawing) + { + stop_calculating=true; + return; + } + + if (csmode==-1 ) return; + + QMouseEvent *event; + if (e->key() == Qt::Key_Left ) + event = new QMouseEvent(QEvent::MouseMove,QPoint(fcx-1,fcy-1),Qt::LeftButton,Qt::LeftButton); + else if (e->key() == Qt::Key_Right ) + event = new QMouseEvent(QEvent::MouseMove,QPoint(fcx+1,fcy+1),Qt::LeftButton,Qt::LeftButton); + else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down) //switch graph in trace mode + { + QValueVector<Ufkt>::iterator it = &m_parser->ufkt[m_parser->ixValue(csmode)]; + int const ke=it->parameters.count(); + if (ke>0) + { + csparam++; + if (csparam >= ke) + csparam=0; + } + if (csparam==0) + { + int const old_csmode=csmode; + char const old_cstype = cstype; + bool start = true; + bool found = false; + while ( 1 ) + { + if ( old_csmode==csmode && !start) + { + cstype=old_cstype; + break; + } + kdDebug() << "csmode: " << csmode << endl; + switch(it->fstr[0].latin1()) + { + case 'x': + case 'y': + case 'r': + break; + default: + { + for (cstype=0;cstype<3;cstype++) //going through the function, the first and the second derivative + { + if (start) + { + if ( cstype==2) + cstype=0; + else + cstype=old_cstype+1; + start=false; + } + kdDebug() << " cstype: " << (int)cstype << endl; + switch (cstype) + { + case (0): + if (it->f_mode ) + found=true; + break; + case (1): + if ( it->f1_mode ) + found=true; + break; + case (2): + if ( it->f2_mode ) + found=true; + break; + } + if (found) + break; + } + break; + } + } + if (found) + break; + + if ( ++it == m_parser->ufkt.end()) + it = m_parser->ufkt.begin(); + csmode = it->id; + } + } + + kdDebug() << "************************" << endl; + kdDebug() << "csmode: " << (int)csmode << endl; + kdDebug() << "cstype: " << (int)cstype << endl; + kdDebug() << "csparam: " << csparam << endl; + + //change function in the statusbar + switch (cstype ) +{ + case 0: + setStatusBar(it->fstr,4); + break; + case 1: + { + QString function = it->fstr; + function = function.left(function.find('(')) + '\''; + setStatusBar(function,4); + break; + } + case 2: + { + QString function = it->fstr; + function = function.left(function.find('(')) + "\'\'"; + setStatusBar(function,4); + break; + } + } + event = new QMouseEvent(QEvent::MouseMove,QPoint(fcx,fcy),Qt::LeftButton,Qt::LeftButton); + } + else if ( e->key() == Qt::Key_Space ) + { + event = new QMouseEvent(QEvent::MouseButtonPress,QCursor::pos(),Qt::RightButton,Qt::RightButton); + mousePressEvent(event); + delete event; + return; + } + else + { + event = new QMouseEvent(QEvent::MouseButtonPress,QPoint(fcx,fcy),Qt::LeftButton,Qt::LeftButton); + mousePressEvent(event); + delete event; + return; + } + mouseMoveEvent(event); + delete event; +} + +void View::areaUnderGraph( Ufkt *ufkt, char const p_mode, double &dmin, double &dmax, const QString &str_parameter, QPainter *DC ) +{ + double x, y = 0; + float calculated_area=0; + int rectheight; + areaMin = dmin; + QPoint p; + QColor color; + switch(p_mode) + { + case 0: + color = ufkt->color; + break; + case 1: + color = ufkt->f1_color; + break; + case 2: + color = ufkt->f2_color; + break; + case 3: + color = ufkt->integral_color; + break; + } + if ( DC == 0) //screen + { + int ly; + buffer.fill(backgroundcolor); + DC = new QPainter(&buffer); + ly=(int)((ymax-ymin)*100.*drskaly/tlgy); + DC->scale((float)h/(float)(ly+2*ref.y()), (float)h/(float)(ly+2*ref.y())); + } + + if(dmin==dmax) //no special plot range is specified. Use the screen border instead. + { + dmin=xmin; + dmax=xmax; + } + + // TODO: parameter sliders + if ( !ufkt->parameters.isEmpty() ) + { + for ( QValueList<ParameterValueItem>::Iterator it = ufkt->parameters.begin(); it != ufkt->parameters.end(); ++it ) + { + if ( (*it).expression == str_parameter) + { + ufkt->setParameter((*it).value); + break; + } + } + } + double dx; + if ( p_mode == 3) + { + stop_calculating = false; + if ( ufkt->integral_use_precision ) + dx = ufkt->integral_precision*(dmax-dmin)/area.width(); + else + dx = stepWidth*(dmax-dmin)/area.width(); + startProgressBar((int)double((dmax-dmin)/dx)/2); + x = ufkt->oldx = ufkt->startx; //the initial x-point + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + //paintEvent(0); + + /*QPainter p; + p.begin(this); + bitBlt( this, 0, 0, &buffer, 0, 0, width(), height() ); + p.end();*/ + } + else + { + dx = stepWidth*(dmax-dmin)/area.width(); + x=dmin; + } + + + int const origoy = dgr.Transy(0.0); + int const rectwidth = dgr.Transx(dx)- dgr.Transx(0.0)+1; + + setCursor(Qt::WaitCursor ); + isDrawing=true; + + bool forward_direction; + if (dmin<0 && dmax<0) + forward_direction = false; + else + forward_direction = true; + + int intervals = qRound((dmax-dmin)/dx); + int at = 0; + + while ((at<=intervals) || (p_mode == 3 && x>=dmin && !forward_direction) || (p_mode == 3 && x<=dmax && forward_direction)) + { + if ( p_mode != 3 ) + x = (intervals-at)*dmin + at*dmax; + ++at; + + if ( p_mode == 3 && stop_calculating) + { + if (forward_direction) + x=dmin-1; + else + x=dmax+1; + break; + continue; + } + switch(p_mode) + { + case 0: + y=m_parser->fkt( ufkt, x); + break; + + case 1: + y=m_parser->a1fkt( ufkt, x); + break; + case 2: + y=m_parser->a2fkt( ufkt, x); + break; + case 3: + { + y = m_parser->euler_method(x, ufkt); + if ( int(x*100)%2==0) + { + KApplication::kApplication()->processEvents(); //makes the program usable when drawing a complicated integral function + increaseProgressBar(); + } + break; + } + } + + p.setX(dgr.Transx(x)); + p.setY(dgr.Transy(y)); + if (dmin<=x && x<=dmax) + { + if( dgr.xclipflg || dgr.yclipflg ) //out of bounds + { + if (y>-10e10 && y<10e10) + { + if ( y<0) + rectheight = origoy-p.y() ; + else + rectheight= -1*( p.y()-origoy); + calculated_area = calculated_area + ( dx*y); + DC->fillRect(p.x(),p.y(),rectwidth,rectheight,color); + } + } + else + { + if ( y<0) + rectheight = origoy-p.y(); + else + rectheight = -1*( p.y()-origoy); + + calculated_area = calculated_area + (dx*y); + /*kdDebug() << "Area: " << area << endl; + kdDebug() << "x:" << p.height() << endl; + kdDebug() << "y:" << p.y() << endl; + kdDebug() << "*************" << endl;*/ + + DC->fillRect(p.x(),p.y(),rectwidth,rectheight,color); + } + } + + if (p_mode==3) + { + if ( forward_direction) + { + x=x+dx; + if (x>dmax && p_mode== 3) + { + forward_direction = false; + x = ufkt->oldx = ufkt->startx; + ufkt->oldy = ufkt->starty; + ufkt->oldyprim = ufkt->integral_precision; + paintEvent(0); + } + } + else + x=x-dx; // go backwards + } + else + x=x+dx; + } + if ( stopProgressBar() ) + { + if( stop_calculating) + { + KMessageBox::error(this,i18n("The drawing was cancelled by the user.")); + isDrawing=false; + restoreCursor(); + return; + } + } + isDrawing=false; + restoreCursor(); + + + areaUfkt = ufkt; + areaPMode = p_mode; + areaMax = dmax; + areaParameter = str_parameter; + + if ( DC->device() == &buffer) //draw the graphs to the screen + { + areaDraw=true; + DC->end(); + setFocus(); + update(); + draw(&buffer,0); + } + + if ( calculated_area>0) + dmin = int(calculated_area*1000)/double(1000); + else + dmin = int(calculated_area*1000)/double(1000)*-1; //don't answer with a negative number +} + +bool View::isCalculationStopped() +{ + if ( stop_calculating) + { + stop_calculating = false; + return true; + } + else + return false; +} + +void View::updateSliders() +{ + for( int number = 0; number < SLIDER_COUNT; number++) + { + if (sliders[ number ]) + { + sliders[ number ]->hide(); + mnuSliders[ number ]->setChecked(false); //uncheck the slider-item in the menu + } + } + + for(QValueVector<Ufkt>::iterator it=m_parser->ufkt.begin(); it!=m_parser->ufkt.end(); ++it) + { + if (it->fname.isEmpty() ) continue; + if( it->use_slider > -1 && (it->f_mode || it->f1_mode || it->f2_mode || it->integral_mode)) + { + // create the slider if it not exists already + if ( sliders[ it->use_slider ] == 0 ) + { + sliders[ it->use_slider ] = new KSliderWindow( this, it->use_slider); + connect( sliders[ it->use_slider ]->slider, SIGNAL( valueChanged( int ) ), this, SLOT( drawPlot() ) ); + connect( sliders[ it->use_slider ], SIGNAL( windowClosed( int ) ), this , SLOT( sliderWindowClosed(int) ) ); + mnuSliders[ it->use_slider ]->setChecked(true); //set the slider-item in the menu + } + sliders[ it->use_slider ]->show(); + } + } +} + +void View::mnuHide_clicked() +{ + if ( csmode == -1 ) + return; + + Ufkt *ufkt = &m_parser->ufkt[ m_parser->ixValue(csmode)]; + switch (cstype ) + { + case 0: + ufkt->f_mode=0; + break; + case 1: + ufkt->f1_mode=0; + break; + case 2: + ufkt->f2_mode=0; + break; + } + drawPlot(); + m_modified = true; + updateSliders(); + if (csmode==-1) + return; + if ( !ufkt->f_mode && !ufkt->f1_mode && !ufkt->f2_mode) //all graphs for the function are hidden + { + csmode=-1; + QMouseEvent *event = new QMouseEvent(QMouseEvent::KeyPress,QCursor::pos(),Qt::LeftButton,Qt::LeftButton); + mousePressEvent(event); //leave trace mode + delete event; + return; + } + else + { + QKeyEvent *event = new QKeyEvent(QKeyEvent::KeyPress,Qt::Key_Up ,Qt::Key_Up ,0); + keyPressEvent(event); //change selected graph + delete event; + return; + } +} +void View::mnuRemove_clicked() +{ + if ( csmode == -1 ) + return; + + if ( KMessageBox::warningContinueCancel(this,i18n("Are you sure you want to remove this function?"), QString::null, KStdGuiItem::del()) == KMessageBox::Continue ) + { + Ufkt *ufkt = &m_parser->ufkt[m_parser->ixValue(csmode)]; + char const function_type = ufkt->fstr[0].latin1(); + if (!m_parser->delfkt( ufkt )) + return; + + if (csmode!=-1) // if trace mode is enabled + { + csmode=-1; + QMouseEvent *event = new QMouseEvent(QMouseEvent::KeyPress,QCursor::pos(),Qt::LeftButton,Qt::LeftButton); + mousePressEvent(event); //leave trace mode + delete event; + } + + drawPlot(); + if ( function_type != 'x' && function_type != 'y' && function_type != 'r' ) + updateSliders(); + m_modified = true; + } +} +void View::mnuEdit_clicked() +{ + if ( csmode == -1 ) + return; + if ( m_parser->ufkt[m_parser->ixValue(csmode)].fstr[0] == 'x') // a parametric function + { + int y_index = csmode+1; //the y-function + if ( y_index == (int)m_parser->countFunctions()) + y_index=0; + KEditParametric* editParametric = new KEditParametric( m_parser, this ); + editParametric->setCaption(i18n( "New Parametric Plot" )); + editParametric->initDialog( csmode,y_index ); + if( editParametric->exec() == QDialog::Accepted ) + { + drawPlot(); + m_modified = true; + } + + } + else // a plot function + { + EditFunction* editFunction = new EditFunction( m_parser, this ); + editFunction->setCaption(i18n( "Edit Function Plot" )); + editFunction->initDialog( csmode ); + if( editFunction->exec() == QDialog::Accepted ) + { + drawPlot(); + updateSliders(); + m_modified = true; + } + } +} + +void View::mnuCopy_clicked() +{ + if ( csmode == -1 ) + return; + + if ( m_parser->sendFunction(csmode) ) + m_modified = true; +} + +void View::mnuMove_clicked() +{ + if ( csmode == -1 ) + return; + + if ( m_parser->sendFunction(csmode) ) + { + if (!m_parser->delfkt(csmode) ) + return; + drawPlot(); + m_modified = true; + } +} + +void View::mnuNoZoom_clicked() +{ + setCursor(Qt::ArrowCursor); + zoom_mode = Z_Normal; +} + +void View::mnuRectangular_clicked() +{ + if ( zoom_mode == Z_Rectangular ) + resetZoom(); + else + { + setCursor(Qt::CrossCursor); + zoom_mode = Z_Rectangular; + } +} +void View::mnuZoomIn_clicked() +{ + if ( zoom_mode == Z_ZoomIn ) + resetZoom(); + else + { + setCursor( QCursor( SmallIcon( "magnify", 32), 10, 10 ) ); + zoom_mode = Z_ZoomIn; + } +} + +void View::mnuZoomOut_clicked() +{ + if ( zoom_mode == Z_ZoomOut ) + resetZoom(); + else + { + setCursor( QCursor( SmallIcon( "lessen", 32), 10, 10 ) ); + zoom_mode = Z_ZoomOut; + } +} +void View::mnuCenter_clicked() +{ + if ( zoom_mode == Z_Center ) + resetZoom(); + else + { + setCursor(Qt::PointingHandCursor); + zoom_mode = Z_Center; + } +} +void View::mnuTrig_clicked() +{ + if ( Settings::anglemode()==0 ) //radians + { + Settings::setXMin("-(47/24)pi"); + Settings::setXMax("(47/24)pi"); + } + else //degrees + { + Settings::setXMin("-352.5" ); + Settings::setXMax("352.5" ); + } + Settings::setYMin("-4"); + Settings::setYMax("4"); + + Settings::setXRange(4); //custom x-range + Settings::setYRange(4); //custom y-range + drawPlot(); //update all graphs +} +void View::invertColor(QColor &org, QColor &inv) +{ + int r = org.red()-255; + if ( r<0) r=r*-1; + int g = org.green()-255; + if ( g<0) g=g*-1; + int b = org.blue()-255; + if ( b<0) b=b*-1; + + inv.setRgb(r,g,b); +} +void View::restoreCursor() +{ + switch (zoom_mode) + { + case Z_Normal: //no zoom + setCursor(Qt::ArrowCursor); + break; + case Z_Rectangular: //rectangle zoom + setCursor(Qt::CrossCursor); + break; + case Z_ZoomIn: //zoom in + setCursor( QCursor( SmallIcon( "magnify", 32), 10, 10 ) ); + break; + case Z_ZoomOut: //zoom out + setCursor( QCursor( SmallIcon( "lessen", 32), 10, 10 ) ); + break; + case Z_Center: //center a point + setCursor(Qt::PointingHandCursor); + break; + } +} + +bool View::event( QEvent * e ) +{ + if ( e->type() == QEvent::WindowDeactivate && isDrawing) + { + stop_calculating = true; + return true; + } + return QWidget::event(e); //send the information further +} + +void View::setStatusBar(const QString &text, const int id) +{ + if ( m_readonly) //if KmPlot is shown as a KPart with e.g Konqueror, it is only possible to change the status bar in one way: to call setStatusBarText + { + switch (id) + { + case 1: + m_statusbartext1 = text; + break; + case 2: + m_statusbartext2 = text; + break; + case 3: + m_statusbartext3 = text; + break; + case 4: + m_statusbartext4 = text; + break; + default: + return; + } + QString statusbartext = m_statusbartext1; + if ( !m_statusbartext1.isEmpty() && !m_statusbartext2.isEmpty() ) + statusbartext.append(" | "); + statusbartext.append(m_statusbartext2); + if ( !m_statusbartext2.isEmpty() && !m_statusbartext3.isEmpty() ) + statusbartext.append(" | "); + statusbartext.append(m_statusbartext3); + if ( (!m_statusbartext2.isEmpty() || !m_statusbartext3.isEmpty() ) && !m_statusbartext4.isEmpty() ) + statusbartext.append(" | "); + statusbartext.append(m_statusbartext4); + emit setStatusBarText(statusbartext); + } + else + { + QByteArray parameters; + QDataStream arg( parameters, IO_WriteOnly); + arg << text << id; + m_dcop_client->send(m_dcop_client->appId(), "KmPlotShell","setStatusBarText(QString,int)", parameters); + } +} +void View::startProgressBar(int steps) +{ + QByteArray data; + QDataStream stream(data, IO_WriteOnly); + stream << steps; + m_dcop_client->send(m_dcop_client->appId(), "KmPlotShell","startProgressBar(int)", data); +} +bool View::stopProgressBar() +{ + QCString replyType; + QByteArray replyData; + m_dcop_client->call(m_dcop_client->appId(), "KmPlotShell","stopProgressBar()", QByteArray(), replyType, replyData); + bool result; + QDataStream stream(replyData, IO_ReadOnly); + stream >> result; + return result; +} +void View::increaseProgressBar() +{ + m_dcop_client->send(m_dcop_client->appId(), "KmPlotShell","increaseProgressBar()", QByteArray()); +} + +void View::sliderWindowClosed(int num) +{ + mnuSliders[num]->setChecked(false); +} diff --git a/kmplot/kmplot/View.h b/kmplot/kmplot/View.h new file mode 100644 index 00000000..a3079c92 --- /dev/null +++ b/kmplot/kmplot/View.h @@ -0,0 +1,273 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef View_included +#define View_included +#undef GrayScale + +// Qt includes +#include <qpixmap.h> + +// KDE includes +#include <dcopclient.h> +#include <kactionclasses.h> +#include <kdebug.h> +#include <kpopupmenu.h> +#include <kprinter.h> +#include <kprogress.h> +#include <kpushbutton.h> + + +// local includes +#include "diagr.h" +#include "Viewiface.h" +#include "xparser.h" + +class XParser; +class KMinMax; +class KSliderWindow; + +enum ZoomMode +{ + Z_Normal = 0, + Z_Rectangular = 1, + Z_ZoomIn = 2, + Z_ZoomOut = 3, + Z_Center = 4 +}; + +/** + * @short This class contains the plots. + * + * It is the central widget of MainDlg. + * @see MainDlg, MainDlg::view + */ +class View : public QWidget, virtual public ViewIface +{ + Q_OBJECT +public: + /// Contructor sets up the parser, too. + View(bool, bool &, KPopupMenu *, QWidget* parent=NULL, const char* name=NULL ); + void setMinMaxDlg(KMinMax *); + virtual ~View(); + + /// Reimplemented to draw all stuff to the view. + void draw(QPaintDevice *, int const); + /// Getting all relevant settings using KConfig XT class Settings. + void getSettings(); + /// Clears all functions in the parser and gets default settings. + /// @see getSettings + void init(); + /// Finding the minimum or maximum value + void findMinMaxValue(Ufkt *, char, bool, double &, double &,const QString &); + /// get a y-value from a x-value + void getYValue(Ufkt * , char, double , double &,const QString &); + /// draw and calculate the area between the graph and the x-axis. + void areaUnderGraph(Ufkt *, char const, double &, double &, const QString &, QPainter* ); + /// the calculation was cancelled by the user + bool isCalculationStopped(); + + /// Returns a pointer to the private parser instance m_parser. + /// @see m_parser + XParser* parser(); + + /** Current plot range endge. */ + static double xmin; + static double xmax; + + /// trace mode stuff, must be accessible in KMinMax + int csmode, csparam; + char cstype; + + /// for areadrawing when printing + bool areaDraw; + Ufkt * areaUfkt; + char areaPMode; + double areaMin, areaMax; + QString areaParameter; + + /// Slider controlling parameter values + KSliderWindow* sliders[ SLIDER_COUNT ]; + /// Menu actions for the sliders + KToggleAction *mnuSliders[ SLIDER_COUNT ]; + void updateSliders(); /// show only needed sliders + +public slots: + /// Called when the user want to cancel the drawing + void stopDrawing(); + /// A slider window has been closed + void sliderWindowClosed(int); + + /// Called when the graph should be updated + void drawPlot(); + ///Slots for the three first items in popup menu + void mnuCopy_clicked(); + void mnuMove_clicked(); + void mnuHide_clicked(); + void mnuRemove_clicked(); + void mnuEdit_clicked(); + ///Slots for the zoom menu + void mnuNoZoom_clicked(); + void mnuRectangular_clicked(); + void mnuZoomIn_clicked(); + void mnuZoomOut_clicked(); + void mnuCenter_clicked(); + void mnuTrig_clicked(); + +protected slots: + void paintEvent(QPaintEvent *); + void resizeEvent(QResizeEvent *); + /// Updating the cross hair. + void mouseMoveEvent(QMouseEvent *); + /// Toggles the trace mode if the cursor is near to a plot. + void mousePressEvent(QMouseEvent *); + /// when a key is pressed and the graph widget has focus + void keyPressEvent(QKeyEvent * ); + /// called when a mouse key is released + void mouseReleaseEvent ( QMouseEvent * e ); + /// Is needed to be reimplement so that the user can stop a preview-drawing + bool event( QEvent * e ); + +signals: + void setStatusBarText(const QString &); + void resetZoom(); + +private: + /// Print out table with additional information. + /// Only for printing. + void drawHeaderTable(QPainter *); + /// Draw the function plots. + void plotfkt(Ufkt *ufkt, QPainter*); + /// Gets the greek pi symbol. + void setpi(QString *); + /// in trace mode checks, if the function is (near by) zero + bool root(double *, Ufkt *); + ///return the inverted color + void invertColor(QColor &, QColor &); + /// Restore the mouse cursor when a drawing is finished + void restoreCursor(); + /// Changes the text in the statusbar + void setStatusBar(const QString &text, const int id); + /// Functions for the progressbar + bool stopProgressBar(); + void startProgressBar(int); + void increaseProgressBar(); + + /// The central parser instance. + /// @see parser() + XParser *m_parser; + + int w, h; + float s; + + /// @name Crosshair + /// Crosshair support. + //@{ + int fcx; ///< x-position of the crosshais (pixel) + int fcy; ///< y-position of the crosshais (pixel) + float csxpos; ///< y-position of the cross hair (real coordinates) + float csypos; ///< x-position of the cross hair (real coordinates) + //@} + /// trace mode stuff + int csflg; + bool rootflg; + + CDiagr dgr; ///< Coordinate system + QPoint ref; + QRect area, + PlotArea; + QPixmap hline, + vline; + QWMatrix wm; + + double tlgx, tlgy, drskalx, drskaly; + QString tlgxstr, tlgystr, drskalxstr, drskalystr; + double stepWidth; ///< Absolute step width + + /** @name Plotrange + * There are 4 predefined plot ranges: + * @li 0: -8..8 + * @li 1: -5..5 + * @li 2: 0..16 + * @li 3: 0..10 + * @li 4: custom + */ + //@{ + ///Convert axes range predefinition index to boundaries. + void getMinMax(int koord, QString &mini, QString &maxi); + /** Handle predefiend axes ranges. + * + * @p koord can have the values 0 to 4 which have the following meanings: + * + * In the last case @p minstr and @p maxstr are evaluated. + */ + void coordToMinMax( const int koord, const QString &minStr, const QString &maxStr, + double &min, double &max ); + /// Sets the plot range from Settings + void setPlotRange(); + //@{ + /** Current plot range endge. */ + double ymin; + double ymax; + //@} + //@} + + void setScaling(); + /// represents the KPrinter option app-kmplot-printtable. + /// @see KPrinterDlg + bool m_printHeaderTable; + /// if stop_calculating is true, the user has canceled drawing of an integral graph + bool stop_calculating; + /// the background color of the graph + QColor backgroundcolor; + /// the inverted background color used by the "Fadenkreuz" + QColor inverted_backgroundcolor; + /// pointer to KMinMax + KMinMax *m_minmax; + ///buffer the current window so all functions don't need to be re-drawed + QPixmap buffer; + /// the popup menu + KPopupMenu *m_popupmenu; + /// is set to true if an integral is calculated + bool isDrawing; + ///status of the popup menu + char m_popupmenushown; /// 0==no popup 1==popup 2==popup+trace mode before + /// for zoom-mode + QPoint rectangle_point; + /*char zoom_mode;*/ ///0=normal 1=rectangular zoom, 2=zoom in, 3=zoom out ,4=drawing a rectangle, 5=center + ZoomMode zoom_mode; + /// true == modifications not saved + bool &m_modified; + /// False if KmPlot is started as a program, otherwise true + bool const m_readonly; + + DCOPClient *m_dcop_client; + QString m_statusbartext1; + QString m_statusbartext2; + QString m_statusbartext3; + QString m_statusbartext4; +}; + +#endif // View_included diff --git a/kmplot/kmplot/Viewiface.h b/kmplot/kmplot/Viewiface.h new file mode 100644 index 00000000..732c7e10 --- /dev/null +++ b/kmplot/kmplot/Viewiface.h @@ -0,0 +1,43 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef VIEWIFACE_H +#define VIEWIFACE_H + +#include <dcopobject.h> + +/** +@author Fredrik Edemar +*/ +/// All functions in ViewIface are accessible with DCOP. For descriptions about the functions, see View. +class ViewIface : virtual public DCOPObject +{ + K_DCOP +k_dcop: + virtual void stopDrawing() = 0; + virtual void drawPlot() = 0; +}; + +#endif diff --git a/kmplot/kmplot/coordsconfigdialog.cpp b/kmplot/kmplot/coordsconfigdialog.cpp new file mode 100644 index 00000000..bc6df41e --- /dev/null +++ b/kmplot/kmplot/coordsconfigdialog.cpp @@ -0,0 +1,90 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include <klocale.h> +#include <klineedit.h> +#include <kmessagebox.h> +#include <qradiobutton.h> + +#include "settings.h" +#include "settingspagecoords.h" +#include "coordsconfigdialog.h" + +CoordsConfigDialog::CoordsConfigDialog(XParser *p, QWidget *parent) + : KConfigDialog(parent, "coords", Settings::self()), m_parser(p) +{ + configAxesDialog = new SettingsPageCoords( 0, "coordsSettings" ); + addPage(configAxesDialog , i18n( "Coords" ), "coords", i18n( "Edit Coordinate System" ) ); + setHelp("axes-config"); +} + +CoordsConfigDialog::~CoordsConfigDialog() +{ +} + +bool CoordsConfigDialog::evalX() +{ + double const min = m_parser->eval( configAxesDialog->kcfg_XMin->text() ); + if ( m_parser->parserError()!=0 ) + return false; + double const max = m_parser->eval( configAxesDialog->kcfg_XMax->text() ); + if ( m_parser->parserError()!=0 ) + return false; + if ( min >= max ) + { + KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value")); + return false; + } + return true; +} +bool CoordsConfigDialog::evalY() +{ + double const min = m_parser->eval( configAxesDialog->kcfg_YMin->text() ); + if ( m_parser->parserError()!=0 ) + return false; + double const max = m_parser->eval( configAxesDialog->kcfg_YMax->text() ); + if ( m_parser->parserError()!=0 ) + return false; + if ( min >= max ) + { + KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value")); + return false; + } + return true; +} + +void CoordsConfigDialog::slotOk() +{ + if ( !(configAxesDialog->radioButton1_4->isChecked() && !evalX()) && !(configAxesDialog->radioButton1_4_2->isChecked() && !evalY())) + KConfigDialog::slotOk(); +} + +void CoordsConfigDialog::slotApply() +{ + if ( !(configAxesDialog->radioButton1_4->isChecked() && !evalX()) && !(configAxesDialog->radioButton1_4_2->isChecked() && !evalY())) + KConfigDialog::slotApply(); +} + +#include "coordsconfigdialog.moc" diff --git a/kmplot/kmplot/coordsconfigdialog.h b/kmplot/kmplot/coordsconfigdialog.h new file mode 100644 index 00000000..f7f8cc48 --- /dev/null +++ b/kmplot/kmplot/coordsconfigdialog.h @@ -0,0 +1,56 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef COORDSCONFIGDIALOG_H +#define COORDSCONFIGDIALOG_H + +#include <kconfigdialog.h> + +#include "xparser.h" + +class SettingsPageCoords; + +/** +@author Fredrik Edemar +*/ +/// +class CoordsConfigDialog : public KConfigDialog +{ + Q_OBJECT + public: + CoordsConfigDialog(XParser *p, QWidget *parent = 0); + ~CoordsConfigDialog(); + protected slots: + virtual void slotOk(); + virtual void slotApply(); + private: + bool evalX(); + bool evalY(); + + Parser *m_parser; + SettingsPageCoords* configAxesDialog; +}; + +#endif diff --git a/kmplot/kmplot/diagr.cpp b/kmplot/kmplot/diagr.cpp new file mode 100644 index 00000000..ba438c7b --- /dev/null +++ b/kmplot/kmplot/diagr.cpp @@ -0,0 +1,653 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +//local includes +#include "diagr.h" +#include "settings.h" + +#ifdef __osf__ +#include <nan.h> +#define isnan(x) IsNAN(x) +#define isinf(x) IsINF(X) +#endif + +#ifdef USE_SOLARIS +#include <ieeefp.h> +int isinf(double x) +{ + return !finite(x) && x==x; +} +#endif + +#include <kdebug.h> + +CDiagr::CDiagr() +{ + frameColor=qRgb(0, 0, 0); + axesColor=qRgb(0, 0, 0); + gridColor=qRgb(192, 192, 192); + borderThickness=2; + axesLineWidth = Settings::axesLineWidth(); + gridLineWidth = Settings::gridLineWidth(); + ticWidth = Settings::ticWidth(); + ticLength = Settings::ticLength(); + g_mode = Settings::gridStyle(); + ex=ey=1.; +} + + +CDiagr::~CDiagr() +{} + +void CDiagr::Create(QPoint Ref, // Bezugspunkt links unten + int lx, int ly, // Achsenl�gen + double xmin, double xmax, // x-Wertebereich + double ymin, double ymax) // y-Wertebereich +{ int x, y, h, w; + + CDiagr::xmin=xmin; // globale Variablen setzen + CDiagr::xmax=xmax; + CDiagr::ymin=ymin; + CDiagr::ymax=ymax; + xmd=xmax+1e-6; + ymd=ymax+1e-6; + tsx=ceil(xmin/ex)*ex; + tsy=ceil(ymin/ey)*ey; + skx=lx/(xmax-xmin); // Skalierungsfaktoren berechnen + sky=ly/(ymax-ymin); + ox=Ref.x()-skx*xmin+0.5; // Ursprungskoordinaten berechnen + oy=Ref.y()+sky*ymax+0.5; + PlotArea.setRect(x=Ref.x(), y=Ref.y(), w=lx, h=ly); + if( Settings::showExtraFrame() ) + { + x-=20; + y-=20; + w+=40; + h+=40; + + if( Settings::showLabel() && ymin>=0. ) + h+=60; + } + + m_frame.setRect(x, y, w, h); +} + + +void CDiagr::Skal( double ex, double ey ) +{ + CDiagr::ex=ex; + CDiagr::ey=ey; + g_mode = Settings::gridStyle(); + tsx=ceil(xmin/ex)*ex; + tsy=ceil(ymin/ey)*ey; +} + + +void CDiagr::Plot(QPainter* pDC) +{ + QPen pen(frameColor, borderThickness); + + if( g_mode != GRID_NONE ) + drawGrid( pDC ); // draw the grid + drawAxes( pDC ); // draw the axes + if( Settings::showLabel() ) + drawLabels(pDC); // Achsen beschriften + if( Settings::showFrame() || Settings::showExtraFrame() )// FRAME zeichnen + { + pDC->setPen(pen); + pDC->drawRect(m_frame); + } +} + + +int CDiagr::Transx( double x ) // reale x-Koordinate +{ + int xi; // transformierte x-Koordinate + static double lastx; // vorherige x-Koordinate + if(isnan(x)) + { + xclipflg=1; + if(lastx<1. && lastx>-1.) + xi=(int)(ox-skx*lastx); + else + xi=(lastx<0)? PlotArea.left(): PlotArea.right(); + } + else if(isinf(x)==-1) + { + xclipflg=0; + xi=PlotArea.left(); + } + else if(isinf(x)==1) + { + xclipflg=0; + xi=PlotArea.right(); + + } + else if(x<xmin) + { + xclipflg=1; + xi=PlotArea.left(); + } + else if(x>xmax) + { + xclipflg=1; + xi=PlotArea.right(); + } + else + { + xclipflg=0; + xi=(int)(ox+skx*x); + } + + lastx=x; + return xi; +} + + +int CDiagr::Transy(double y) // reale y-Koordinate +{ + int yi; // transformierte y-Koordinate + static double lasty; // vorherige y-Koordinate + if(isnan(y)) + { + yclipflg=1; + if(lasty<1. && lasty>-1.) + yi=(int)(oy-sky*lasty); + else + yi=(lasty<0)? PlotArea.bottom(): PlotArea.top(); + } + else if(isinf(y)==-1) + { + yclipflg=0; + yi=PlotArea.bottom(); + + } + else if(isinf(y)==1) + { + yclipflg=0; + yi=PlotArea.top(); + + } + else if(y<ymin) + { + yclipflg=1; + yi=PlotArea.bottom(); + } + else if(y>ymax) + { + yclipflg=1; + yi=PlotArea.top(); + } + else + { + yclipflg=0; + yi=(int)(oy-sky*y); + } + + lasty=y; + return yi; +} + + +double CDiagr::Transx(int x) // Bildschirmkoordinate +{ return (x-ox)/skx; // reale x-Koordinate +} + + +double CDiagr::Transy(int y) // Bildschirmkoordinate +{ return (oy-y)/sky; // reale y-Koordinate +} + + +void CDiagr::drawAxes( QPainter* pDC ) // draw axes +{ int a, b, tl; + double d, da, db; + + if( Settings::showAxes() ) + { + pDC->setPen( QPen( axesColor, axesLineWidth ) ); + b = Transy(0.); + a = PlotArea.right(); + pDC->Lineh(PlotArea.left(), b, a); // x-Achse + if( Settings::showArrows()) // ARROWS + { int const dx=40; + int const dy=15; + pDC->Line(a, b, a-dx, b+dy); + pDC->Line(a, b, a-dx, b-dy); + } + + a = Transx(0.); + b = PlotArea.top(); + pDC->Linev(a, PlotArea.bottom(), b); // y-Achse + if( Settings::showArrows() ) // ARROWS + { int const dx=15; + int const dy=40; + pDC->Line(a, b, a-dx, b+dy); + pDC->Line(a, b, a+dx, b+dy); + } + } + + pDC->setPen( QPen( axesColor, ticWidth ) ); + if( Settings::showAxes() ) + { + da=oy-ticLength; + db=oy+ticLength; + tl= Settings::showFrame()? 0: ticLength; + d=tsx; + if(da<(double)PlotArea.top()) + { + a=PlotArea.top()-tl; + b=PlotArea.top()+ticLength; + } + else if(db>(double)PlotArea.bottom()) + { + b=PlotArea.bottom()+tl; + a=PlotArea.bottom()-ticLength; + } + else + { + a=(int)da; + b=(int)db; + } + + while(d<xmd-ex/2.) + { + pDC->Linev(Transx(d), a, b); + d+=ex; + } + + da=ox-ticLength; + db=ox+ticLength; + d=tsy; + if(da<(double)PlotArea.left()) + { + a=PlotArea.left()-tl; + b=PlotArea.left()+ticLength; + } + else if(db>(double)PlotArea.right()) + { + b=PlotArea.right()+tl; + a=PlotArea.right()-ticLength; + } + else + { + a=(int)da; + b=(int)db; + } + + while(d<ymd-ey/2.) + { + pDC->Lineh(a, Transy(d), b); + d+=ey; + } + } + else if( Settings::showFrame() ) + { + a=PlotArea.bottom()+ticLength; + b=PlotArea.top()-ticLength; + d=tsx; + while(d<xmd) + { + pDC->Linev(Transx(d), PlotArea.bottom(), a); + pDC->Linev(Transx(d), PlotArea.top(), b); + d+=ex; + } + + a=PlotArea.left()+ticLength; + b=PlotArea.right()-ticLength; + d=tsy; + while(d<ymd) + { + pDC->Lineh(PlotArea.left(), Transy(d), a); + pDC->Lineh(PlotArea.right(), Transy(d), b); + d+=ey; + } + } +} + + +void CDiagr::drawGrid( QPainter* pDC ) +{ + int a, b; + double d, x, y; + QPen pen( gridColor, gridLineWidth ); + + pDC->setPen(pen); + if( g_mode==GRID_LINES ) + { + d=tsx; + while(d<xmd) + { + pDC->Linev(Transx(d), PlotArea.bottom(), PlotArea.top()); + d+=ex; + } + d=tsy; + while(d<ymd) + { + pDC->Lineh(PlotArea.left(), Transy(d), PlotArea.right()); + d+=ey; + } + } + else if( g_mode==GRID_CROSSES ) + { + int const dx = 5; + int const dy = 5; + + for(x=tsx; x<xmd; x+=ex) + { + a=Transx(x); + for(y=tsy; y<ymd; y+=ey) + { + b=Transy(y); + pDC->Lineh(a-dx, b, a+dx); + pDC->Linev(a, b-dy, b+dy); + } + } + } + else if( g_mode==GRID_POLAR ) + { + int y2; + double w; + QRect const rc=PlotArea; + + pDC->setClipRect(pDC->xForm(rc)); + double const c=hypot(xmd*skx, ymd*sky); + int const xm=(int)(c+ox); + int const dr=(int)(skx*ex); + int const d2r=(int)(2.*skx*ex); + int x1=(int)ox-dr; + int y1=(int)oy-dr; + int x2=y2=d2r; + + do + { + pDC->drawEllipse(x1, y1, x2, y2); + x1-=dr; + y1-=dr; + x2+=d2r; + y2+=d2r; + } + while(x2<=xm); + + x1=(int)ox; + y1=(int)oy; + for(w=0.; w<2.*M_PI; w+=M_PI/12.) + { + x2=(int)(ox+c*cos(w)); + y2=(int)(oy+c*sin(w)); + pDC->Line(x1, y1, x2, y2); + } + pDC->setClipping(false); + } +} + + +void CDiagr::drawLabels(QPainter* pDC) +{ + int const dx=15; + int const dy=40; + QFont const font=QFont( Settings::axesFont(), Settings::axesFontSize() ); + pDC->setFont(font); + int const x=Transx(0.); + int const y=Transy(0.); + double d; + int n; + QString s; + + //pDC->drawText(x-dx, y+dy, 0, 0, Qt::AlignRight|Qt::AlignVCenter|Qt::DontClip, "0"); + char draw_next=0; + QFontMetrics const test(font); + int swidth=0; + + for(d=tsx, n=(int)ceil(xmin/ex); d<xmd; d+=ex, ++n) + { + if(n==0 || fabs(d-xmd)<=1.5*ex) + continue; + + + if(n<0) + s="-"; + else + s="+"; + if(fabs(ex-M_PI/2.)<1e-3) + { + if(n==-1 || n==1) + s+="pi/2";//s+=QChar(960)+QString("/2"); + else if(n%2 == 0) + { + if(n==-2 || n==2) + s+="pi";//s+=QChar(960); + else + { + s=QString().sprintf("%+d", n/2); + s+="pi";//s+=QChar(960); + } + } + else + continue; + swidth = test.width(s); + if ( Transx(d)-x<swidth && Transx(d)-x>-swidth && draw_next==0) + { + draw_next=1; + continue; + } + if (draw_next>0) + { + if (draw_next==1) + { + draw_next++; + continue; + } + else + draw_next=0; + } + pDC->drawText(Transx(d), y+dy, 0, 0, Qt::AlignCenter|Qt::DontClip, s); + } + else if(fabs(ex-M_PI/3.)<1e-3) + { + if(n==-1 || n==1) + s+="pi/3";//s+=QChar(960)+QString("/3"); + else if(n%3==0) + { + if(n==-3 || n==3) + s+="pi";//s+=QChar(960); + else + { + s=QString().sprintf("%+d", n/3); + s+="pi";//s+=QChar(960); + } + } + else + continue; + swidth = test.width(s); + if ( Transx(d)-x<swidth && Transx(d)-x>-swidth && draw_next==0) + { + draw_next=1; + continue; + } + if (draw_next>0) + { + if (draw_next==1) + { + draw_next++; + continue; + } + else + draw_next=0; + } + pDC->drawText(Transx(d), y+dy, 0, 0, Qt::AlignCenter|Qt::DontClip, s); + } + else if(fabs(ex-M_PI/4.)<1e-3) + { + if(n==-1 || n==1) + s+="pi/4";//s+=QChar(960)+QString("/4"); + else if(n%4==0) + { + if(n==-4 || n==4) + s+="pi";//s+=QChar(960); + else + { + s=QString().sprintf("%+d", n/4); + s+="pi";//s+=QChar(960); + } + } + else + continue; + swidth = test.width(s); + if ( Transx(d)-x<swidth && Transx(d)-x>-swidth && draw_next==0) + { + draw_next=1; + continue; + } + if (draw_next>0) + { + if (draw_next==1) + { + draw_next++; + continue; + } + else + draw_next=0; + } + pDC->drawText(Transx(d), y+dy, 0, 0, Qt::AlignCenter|Qt::DontClip, s); + } + else if((n%5==0 || n==1 || n==-1 || draw_next)) + { + s=QString().sprintf("%+0.3g", n*ex); + swidth = test.width(s); + if ( Transx(d)-x<swidth && Transx(d)-x>-swidth && draw_next==0) + { + draw_next=1; + continue; + } + if (draw_next>0) + { + if (draw_next==1) + { + draw_next++; + continue; + } + else + draw_next=0; + } + pDC->drawText(Transx(d), y+dy, 0, 0, Qt::AlignCenter|Qt::DontClip, s); + } + } + + if(ymax<0 && xmax<0) + pDC->drawText(Transx(xmax)-(4*dx), y+(dy-20), 0, 0, Qt::AlignCenter|Qt::DontClip, "x"); + else + pDC->drawText(Transx(xmax)-dx, y+dy, 0, 0, Qt::AlignCenter|Qt::DontClip, "x"); + + for(d=tsy, n=(int)ceil(ymin/ey); d<ymd; d+=ey, ++n) + { + if(n==0 || fabs(d-ymd)<=1.5*ey) + continue; + + if(n<0) + s="-"; + else + s="+"; + + if(fabs(ey-M_PI/2.)<1e-3) + { + if(n==-1 || n==1) + s+="pi/2";//s+=QChar(960)+QString("/2"); + else if(n%2==0) + { + if(n==-2 || n==2) + s+="pi";//s+=QChar(960); + else + { + s=QString().sprintf("%+d", n/2); + s+="pi";//s+=QChar(960); + } + } + else + continue; + if (xmin>=0) + pDC->drawText(x+dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignLeft|Qt::DontClip, s); + else + pDC->drawText(x-dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignRight|Qt::DontClip, s); + } + else if(fabs(ey-M_PI/3.)<1e-3) + { + if(n==-1 || n==1) + s+="pi/3";//s+=QChar(960)+QString("/3"); + else if(n%3==0) + { + if(n==-3 || n==3) + s+="pi";//s+=QChar(960); + else + { + s=QString().sprintf("%+d", n/3); + s+="pi";//s+=QChar(960); + } + } + else + continue; + if (xmin>=0) + pDC->drawText(x+dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignLeft|Qt::DontClip, s); + else + pDC->drawText(x-dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignRight|Qt::DontClip, s); + } + else if(fabs(ey-M_PI/4.)<1e-3) + { + if(n==-1 || n==1) + s+="pi/4";//s+=QChar(960)+QString("/4"); + else if(n%4==0) + { + if(n==-4 || n==4) + s+="pi";//s+=QChar(960); + else + { + s=QString().sprintf("%+d", n/4); + s+="pi";//s+=QChar(960); + } + } + else + continue; + if (xmin>=0) + pDC->drawText(x+dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignLeft|Qt::DontClip, s); + else + pDC->drawText(x-dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignRight|Qt::DontClip, s); + } + else if((n%5==0 || n==1 || n==-1)) + { + s=QString().sprintf("%+0.3g", n*ey); + if (xmin>=0) + pDC->drawText(x+dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignLeft|Qt::DontClip, s); + else + pDC->drawText(x-dx, Transy(d), 0, 0, Qt::AlignVCenter|Qt::AlignRight|Qt::DontClip, s); + } + } + + if(ymax<0 && xmax<0) + pDC->drawText(x-dx, Transy(ymax)+(2*dy), 0, 0, Qt::AlignVCenter|Qt::AlignRight|Qt::DontClip, "y"); + else if (xmin>0) + pDC->drawText(x-(2*dx), Transy(ymax)+dy, 0, 0, Qt::AlignVCenter|Qt::AlignRight|Qt::DontClip, "y"); + else + pDC->drawText(x-dx, Transy(ymax)+dy, 0, 0, Qt::AlignVCenter|Qt::AlignRight|Qt::DontClip, "y"); +} diff --git a/kmplot/kmplot/diagr.h b/kmplot/kmplot/diagr.h new file mode 100644 index 00000000..45cae5a6 --- /dev/null +++ b/kmplot/kmplot/diagr.h @@ -0,0 +1,145 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ +/** @file diagr.h + * @brief Contains the CDiagr class. */ + +#ifndef diagr_included +#define diagr_included + +// standard includes +#include <math.h> +#include <stdio.h> + +// Qt includes +#include <qpainter.h> + +//@{ +/// Some abbreviations for horizontal and vertical lines. +#define Line drawLine +#define Lineh(x1, y, x2) drawLine(x1, y, x2, y) +#define Linev(x, y1, y2) drawLine(x, y1, x, y2) +//@} + +//@{ +/// Grid styles. +#define GRID_NONE 0 +#define GRID_LINES 1 +#define GRID_CROSSES 2 +#define GRID_POLAR 3 +//@} + +/** @short This class manages the core drawing of the axes and the grid. */ +class CDiagr +{ +public: + /// Contructor. Members are set to initial values. + ///@see Create() + CDiagr(); + /// Nothing to do for the destructor. + ~CDiagr(); + + /// Sets all members to current values. + void Create( QPoint Ref, + int lx, int ly, + double xmin, double xmax, + double ymin, double ymax ); + /// Sets the current values for the scaling factors + void Skal( double ex, double ey ); + /// Draws all requested parts of the diagram (axes, labels, grid e.g.) + void Plot( QPainter* pDC ); + /// Returns the rectangle around the core of the plot area. + QRect GetPlotArea() { return PlotArea; } + /// Returns the rectangle for the frame around the plot. Extra frame is bigger. + QRect GetFrame() { return m_frame; } + + /** @name Transformations */ + //@{ + /// These functions convert real coordinates to pixel coordinates and vice versa. + int Transx(double); + int Transy(double); + double Transx(int); + double Transy(int); + //@} + + /** @name Style options + * These members hold the current options for line widths and colors + */ + //@{ + QRgb frameColor; ///< color of the border frame + QRgb axesColor; ///< color of the axes + QRgb gridColor; ///< color of the grid + + uint borderThickness, ///< current line width for the border frame + axesLineWidth, ///< current line width for the axes + gridLineWidth, ///< current line width for the grid + ticWidth, ///< current line width for the tics + ticLength, ///< current length of the tic lines + //@} + xclipflg, ///< clipflg is set to 1 if the plot is out of the plot aerea. + yclipflg; ///< clipflg is set to 1 if the plot is out of the plot aerea. + + +private: + + /// Draw the coordinate axes. + void drawAxes(QPainter*); + /// Draw the grid. + void drawGrid( QPainter* ); + /// Write labels. + void drawLabels(QPainter*); + /// Current grid style. + int g_mode; + + //@{ + /// Plot range edge. + double xmin, xmax, ymin, ymax; + //@} + //@{ + /// Clip boundage. + double xmd, ymd; + //@} + //@{ + /// Axes tic distance. + double ex, ey; + //@} + //@{ + ///Position of the first tic. + double tsx, tsy; + //@} + //@{ + /// Screen coordinates of the coordinate system origin. + double ox, oy; + //@} + //@{ + /// Transformation factors. + /// @see Skal + double skx, sky; + //@} + + QRect PlotArea; ///< plot area + QRect m_frame; ///< frame around the plot +}; + +#endif // diagr_included diff --git a/kmplot/kmplot/editderivativespage.ui b/kmplot/kmplot/editderivativespage.ui new file mode 100644 index 00000000..a6a88b78 --- /dev/null +++ b/kmplot/kmplot/editderivativespage.ui @@ -0,0 +1,276 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>EditDerivativesPage</class> +<widget class="QWidget"> + <property name="name"> + <cstring>EditDerivativesPage</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>323</width> + <height>255</height> + </rect> + </property> + <property name="caption"> + <string>Edit Derivatives</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QFrame"> + <property name="name"> + <cstring>grp1der</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KColorButton" row="2" column="1"> + <property name="name"> + <cstring>colorDerivative1</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>color of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to choose a color for the plot line.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="2"> + <property name="name"> + <cstring>TextLabel2_2_2</cstring> + </property> + <property name="text"> + <string>0.1mm</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel2_2_2</cstring> + </property> + <property name="text"> + <string>&Color:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>colorDerivative1</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="1"> + <property name="name"> + <cstring>lineWidthDerivative1</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>width of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Change the width of the plot line in steps of 0.1mm.</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>showDerivative1</cstring> + </property> + <property name="text"> + <string>Show &1st derivative</string> + </property> + <property name="toolTip" stdset="0"> + <string>Show first derivative</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If this box is checked, the first derivative will be plotted, too.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_3_2_2</cstring> + </property> + <property name="text"> + <string>&Line width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>lineWidthDerivative1</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>grp2der</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string>Colo&r:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>colorDerivative2</cstring> + </property> + </widget> + <widget class="KColorButton" row="2" column="1"> + <property name="name"> + <cstring>colorDerivative2</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>color of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to choose a color for the plot line.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_3_2</cstring> + </property> + <property name="text"> + <string>Line &width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>lineWidthDerivative2</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="1"> + <property name="name"> + <cstring>lineWidthDerivative2</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>width of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Change the width of the plot line in steps of 0.1mm.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="2"> + <property name="name"> + <cstring>TextLabel2_2</cstring> + </property> + <property name="text"> + <string>0.1mm</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>showDerivative2</cstring> + </property> + <property name="text"> + <string>Show &2nd derivative</string> + </property> + <property name="toolTip" stdset="0"> + <string>Show second derivative</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If this box is checked, the first derivative will be plotted, too.</string> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>110</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>showDerivative1</sender> + <signal>toggled(bool)</signal> + <receiver>lineWidthDerivative1</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>showDerivative1</sender> + <signal>toggled(bool)</signal> + <receiver>colorDerivative1</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>showDerivative2</sender> + <signal>toggled(bool)</signal> + <receiver>lineWidthDerivative2</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>showDerivative2</sender> + <signal>toggled(bool)</signal> + <receiver>colorDerivative2</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>showDerivative1</sender> + <signal>toggled(bool)</signal> + <receiver>textLabel1_3_2_2</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>showDerivative1</tabstop> + <tabstop>lineWidthDerivative1</tabstop> + <tabstop>colorDerivative1</tabstop> + <tabstop>showDerivative2</tabstop> + <tabstop>lineWidthDerivative2</tabstop> + <tabstop>colorDerivative2</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/editfunction.cpp b/kmplot/kmplot/editfunction.cpp new file mode 100644 index 00000000..60786d21 --- /dev/null +++ b/kmplot/kmplot/editfunction.cpp @@ -0,0 +1,446 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +// Qt includes +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qdialog.h> +#include <qframe.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qstringlist.h> +#include <qvbox.h> + + +// KDE includes +#include <kapplication.h> +#include <kcolorbutton.h> +#include <kiconloader.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <knuminput.h> +#include <kpushbutton.h> + +#include <kdebug.h> + +// local includes +#include "editfunction.h" +#include "editfunction.moc" +#include "View.h" +#include "editfunctionpage.h" +#include "editderivativespage.h" +#include "editintegralpage.h" +#include "kparametereditor.h" + +EditFunction::EditFunction( XParser* parser, QWidget* parent, const char* name ) : + KDialogBase( IconList, "Caption", Help|Ok|Cancel, Ok, parent, name ), m_parser(parser) +{ + QVBox *page0 = addVBoxPage( i18n("Function"), i18n( "Function" ), SmallIcon( "func", 32 ) ); + editfunctionpage = new EditFunctionPage( page0 ); + QVBox *page1 = addVBoxPage( i18n("Derivatives"), i18n( "Derivatives" ), SmallIcon( "deriv_func", 32 ) ); + editderivativespage = new EditDerivativesPage( page1 ); + QVBox *page2 = addVBoxPage( i18n("Integral"), i18n( "Integral" ), SmallIcon( "integral_func", 32 ) ); + editintegralpage = new EditIntegralPage( page2 ); + for( int number = 0; number < SLIDER_COUNT; number++ ) + { + editfunctionpage->listOfSliders->insertItem( i18n( "Slider No. %1" ).arg( number +1) ); + } + connect( editfunctionpage->cmdParameter, SIGNAL ( clicked() ), this, SLOT( cmdParameter_clicked() ) ); + connect( editfunctionpage->useNoParameter, SIGNAL ( toggled(bool) ), this, SLOT( noParameter_toggled(bool) ) ); + connect( editfunctionpage->customMinRange, SIGNAL ( toggled(bool) ), this, SLOT( customMinRange_toggled(bool) ) ); + connect( editfunctionpage->customMaxRange, SIGNAL ( toggled(bool) ), this, SLOT( customMaxRange_toggled(bool) ) ); + m_updatedfunction = 0; +} + +void EditFunction::initDialog( int id ) +{ + m_id = id; + if( m_id == -1 ) clearWidgets(); //new function, so clear all values + else setWidgets(); + editfunctionpage->equation->setFocus(); +} + +void EditFunction::clearWidgets() +{ + // Clear the Function page + editfunctionpage->equation->clear(); + editfunctionpage->hide->setChecked( false ); + editfunctionpage->customMinRange->setChecked( false ); + editfunctionpage->customMaxRange->setChecked( false ); + editfunctionpage->min->clear(); + editfunctionpage->max->clear(); + editfunctionpage->lineWidth->setValue( m_parser->linewidth0 ); + editfunctionpage->color->setColor( m_parser->defaultColor(m_parser->getNextIndex() ) ); + + // Clear the Derivatives page + editderivativespage->showDerivative1->setChecked( false ); + editderivativespage->lineWidthDerivative1->setValue( editfunctionpage->lineWidth->value() ); + editderivativespage->colorDerivative1->setColor( editfunctionpage->color->color() ); + editderivativespage->showDerivative2->setChecked( false ); + editderivativespage->lineWidthDerivative2->setValue( editfunctionpage->lineWidth->value() ); + editderivativespage->colorDerivative2->setColor( editfunctionpage->color->color() ); + + // Clear the Integral page + editintegralpage->precision->setValue( Settings::stepWidth()); + editintegralpage->color->setColor( editfunctionpage->color->color() ); + editintegralpage->lineWidth->setValue(editfunctionpage->lineWidth->value()); + +} + +void EditFunction::setWidgets() +{ + Ufkt *ufkt = &m_parser->ufkt[ m_parser->ixValue(m_id) ]; + editfunctionpage->equation->setText( ufkt->fstr ); + editfunctionpage->hide->setChecked( !ufkt->f_mode); + editfunctionpage->lineWidth->setValue( ufkt->linewidth ); + editfunctionpage->color->setColor( ufkt->color ); + + if (ufkt->usecustomxmin) + { + editfunctionpage->customMinRange->setChecked(true); + editfunctionpage->min->setText( ufkt->str_dmin ); + } + else + editfunctionpage->customMinRange->setChecked(false); + if (ufkt->usecustomxmax) + { + editfunctionpage->customMaxRange->setChecked(true); + editfunctionpage->max->setText( ufkt->str_dmax ); + } + else + editfunctionpage->customMaxRange->setChecked(false); + + m_parameter = ufkt->parameters; + if( ufkt->use_slider == -1 ) + if ( ufkt->parameters.isEmpty() ) + editfunctionpage->useNoParameter->setChecked( true ); + else + editfunctionpage->useList->setChecked( true ); + else + { + editfunctionpage->useSlider->setChecked( true ); + editfunctionpage->listOfSliders->setCurrentItem( ufkt->use_slider ); + } + + editderivativespage->showDerivative1->setChecked( ufkt->f1_mode ); + editderivativespage->lineWidthDerivative1->setValue( ufkt->f1_linewidth ); + editderivativespage->colorDerivative1->setColor( ufkt->f1_color ); + editderivativespage->showDerivative2->setChecked( ufkt->f2_mode ); + editderivativespage->lineWidthDerivative2->setValue( ufkt->f2_linewidth ); + editderivativespage->colorDerivative2->setColor( ufkt->f2_color ); + editintegralpage->precision->setValue( ufkt->integral_precision ); + editintegralpage->lineWidth->setValue( ufkt->integral_linewidth ); + editintegralpage->color->setColor( ufkt->integral_color ); + + if ( ufkt->integral_mode ) + { + editintegralpage->showIntegral->setChecked( ufkt->integral_mode ); + editintegralpage->customPrecision->setChecked( ufkt->integral_use_precision ); + editintegralpage->txtInitX->setText(ufkt->str_startx); + editintegralpage->txtInitY->setText(ufkt->str_starty); + + } + +} + +void EditFunction::accept() +{ + QString f_str( editfunctionpage->equation->text() ); + + if ( m_id!=-1 ) + m_parser->fixFunctionName(f_str, XParser::Function, m_id); + else + m_parser->fixFunctionName(f_str, XParser::Function); + if ( f_str.at(0)== 'x' || f_str.at(0)== 'y' || f_str.at(0)== 'r') + { + KMessageBox::error( this, i18n("You can only define plot functions in this dialog")); + return; + } + + Ufkt tmp_ufkt; //all settings are saved here until we know that no errors have appeared + if( editfunctionpage->customMinRange->isChecked() ) + { + tmp_ufkt.usecustomxmin = true; + tmp_ufkt.str_dmin = editfunctionpage->min->text(); + tmp_ufkt.dmin = m_parser->eval( editfunctionpage->min->text() ); + if (m_parser->parserError() != 0) + { + showPage(0); + editfunctionpage->min->setFocus(); + editfunctionpage->min->selectAll(); + return; + } + } + else + tmp_ufkt.usecustomxmin = false; + if( editfunctionpage->customMaxRange->isChecked() ) + { + tmp_ufkt.usecustomxmax = true; + tmp_ufkt.str_dmax= editfunctionpage->max->text(); + tmp_ufkt.dmax = m_parser->eval( editfunctionpage->max->text() ); + if (m_parser->parserError() != 0) + { + showPage(0); + editfunctionpage->max->setFocus(); + editfunctionpage->max->selectAll(); + return; + } + } + else + tmp_ufkt.usecustomxmax = false; + + if( tmp_ufkt.usecustomxmin && tmp_ufkt.usecustomxmax ) + { + if ( tmp_ufkt.dmin >= tmp_ufkt.dmax) + { + KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value")); + showPage(0); + editfunctionpage->min->setFocus(); + editfunctionpage->min->selectAll(); + return; + } + + if ( tmp_ufkt.dmin<View::xmin || tmp_ufkt.dmax>View::xmax ) + { + KMessageBox::error(this,i18n("Please insert a minimum and maximum range between %1 and %2").arg(View::xmin).arg(View::xmax) ); + showPage(0); + editfunctionpage->min->setFocus(); + editfunctionpage->min->selectAll(); + return; + } + } + + tmp_ufkt.linewidth = editfunctionpage->lineWidth->value(); + tmp_ufkt.color = editfunctionpage->color->color().rgb(); + + if (editintegralpage->showIntegral->isChecked() ) + { + double initx = m_parser->eval(editintegralpage->txtInitX->text()); + tmp_ufkt.startx = initx; + tmp_ufkt.str_startx = editintegralpage->txtInitX->text(); + if (m_parser->parserError(false) != 0) + { + KMessageBox::error(this,i18n("Please insert a valid x-value")); + showPage(2); + editintegralpage->txtInitX->setFocus(); + editintegralpage->txtInitX->selectAll(); + return; + } + + double inity = m_parser->eval(editintegralpage->txtInitY->text()); + tmp_ufkt.starty = inity; + tmp_ufkt.str_starty = editintegralpage->txtInitY->text(); + if (m_parser->parserError(false) != 0) + { + KMessageBox::error(this,i18n("Please insert a valid y-value")); + showPage(2); + editintegralpage->txtInitY->setFocus(); + editintegralpage->txtInitY->selectAll(); + return; + } + tmp_ufkt.integral_mode = 1; + } + else + tmp_ufkt.integral_mode = 0; + + tmp_ufkt.integral_color = editintegralpage->color->color().rgb(); + tmp_ufkt.integral_use_precision = editintegralpage->customPrecision->isChecked(); + tmp_ufkt.integral_precision = editintegralpage->precision->value(); + tmp_ufkt.integral_linewidth = editintegralpage->lineWidth->value(); + + tmp_ufkt.f_mode = !editfunctionpage->hide->isChecked(); + + if( editfunctionpage->useSlider->isChecked() ) + tmp_ufkt.use_slider = editfunctionpage->listOfSliders->currentItem(); //specify which slider that will be used + else + { + tmp_ufkt.use_slider = -1; + if ( editfunctionpage->useNoParameter->isChecked() || m_parameter.isEmpty() ) + m_parameter.clear(); + else + { + tmp_ufkt.parameters = m_parameter; + } + + } + + tmp_ufkt.f1_mode = editderivativespage->showDerivative1->isChecked(); + tmp_ufkt.f1_linewidth = editderivativespage->lineWidthDerivative1->value(); + tmp_ufkt.f1_color = editderivativespage->colorDerivative1->color().rgb(); + + tmp_ufkt.f2_mode = editderivativespage->showDerivative2->isChecked(); + tmp_ufkt.f2_linewidth = editderivativespage->lineWidthDerivative2->value(); + tmp_ufkt.f2_color = editderivativespage->colorDerivative2->color().rgb(); + + if ( f_str.contains('y') != 0 && ( tmp_ufkt.f_mode || tmp_ufkt.f1_mode || tmp_ufkt.f2_mode) ) + { + KMessageBox::error( this, i18n( "Recursive function is only allowed when drawing integral graphs") ); + return; + } + + Ufkt *added_ufkt; + if( m_id != -1 ) //when editing a function: + { + int const ix = m_parser->ixValue(m_id); + if ( ix == -1) //The function could have been deleted + { + KMessageBox::error(this,i18n("Function could not be found")); + return; + } + added_ufkt = &m_parser->ufkt[ix]; + QString const old_fstr = added_ufkt->fstr; + if(( (!m_parameter.isEmpty() && editfunctionpage->useList->isChecked() ) || editfunctionpage->useSlider->isChecked() ) && !functionHas2Arguments() ) + fixFunctionArguments(f_str); //adding an extra argument for the parameter value + added_ufkt->fstr = f_str; + m_parser->reparse(added_ufkt); //reparse the funcion + if ( m_parser->parserError() != 0) + { + added_ufkt->fstr = old_fstr; + m_parser->reparse(added_ufkt); + raise(); + showPage(0); + editfunctionpage->equation->setFocus(); + editfunctionpage->equation->selectAll(); + return; + } + } + else //creating a new function + { + if(( (!m_parameter.isEmpty() && editfunctionpage->useList->isChecked() ) || editfunctionpage->useSlider->isChecked() ) && !functionHas2Arguments() ) + fixFunctionArguments(f_str); //adding an extra argument for the parameter value + int const id = m_parser->addfkt( f_str ); //create a new function otherwise + if( id == -1) + { + m_parser->parserError(); + raise(); + showPage(0); + editfunctionpage->equation->setFocus(); + editfunctionpage->equation->selectAll(); + return; + } + added_ufkt = &m_parser->ufkt.last(); + } + //save all settings in the function now when we know no errors have appeared + added_ufkt->f_mode = tmp_ufkt.f_mode; + added_ufkt->f1_mode = tmp_ufkt.f1_mode; + added_ufkt->f2_mode = tmp_ufkt.f2_mode; + added_ufkt->integral_mode = tmp_ufkt.integral_mode; + added_ufkt->integral_use_precision = tmp_ufkt.integral_use_precision; + added_ufkt->linewidth = tmp_ufkt.linewidth; + added_ufkt->f1_linewidth = tmp_ufkt.f1_linewidth; + added_ufkt->f2_linewidth = tmp_ufkt.f2_linewidth; + added_ufkt->integral_linewidth = tmp_ufkt.integral_linewidth; + added_ufkt->str_dmin = tmp_ufkt.str_dmin; + added_ufkt->str_dmax = tmp_ufkt.str_dmax; + added_ufkt->dmin = tmp_ufkt.dmin; + added_ufkt->dmax = tmp_ufkt.dmax; + added_ufkt->str_startx = tmp_ufkt.str_startx; + added_ufkt->str_starty = tmp_ufkt.str_starty; + added_ufkt->oldx = tmp_ufkt.oldx; + added_ufkt->starty = tmp_ufkt.starty; + added_ufkt->startx = tmp_ufkt.startx; + added_ufkt->integral_precision = tmp_ufkt.integral_precision; + added_ufkt->color = tmp_ufkt.color; + added_ufkt->f1_color = tmp_ufkt.f1_color; + added_ufkt->f2_color = tmp_ufkt.f2_color; + added_ufkt->integral_color = tmp_ufkt.integral_color; + added_ufkt->parameters = tmp_ufkt.parameters; + added_ufkt->use_slider = tmp_ufkt.use_slider; + added_ufkt->usecustomxmin = tmp_ufkt.usecustomxmin; + added_ufkt->usecustomxmax = tmp_ufkt.usecustomxmax; + + m_updatedfunction = added_ufkt; + + // call inherited method + KDialogBase::accept(); +} + +Ufkt * EditFunction::functionItem() +{ + return m_updatedfunction; +} + +void EditFunction::slotHelp() +{ + kapp->invokeHelp( "", "kmplot" ); +} + +bool EditFunction::functionHas2Arguments() +{ + int const openBracket = editfunctionpage->equation->text().find( "(" ); + int const closeBracket = editfunctionpage->equation->text().find( ")" ); + return editfunctionpage->equation->text().mid( openBracket+1, closeBracket-openBracket-1 ).find( "," ) != -1; +} +void EditFunction::cmdParameter_clicked() +{ + editfunctionpage->useList->setChecked(true); + KParameterEditor *dlg = new KParameterEditor(m_parser,&m_parameter); + dlg->show(); +} +void EditFunction::noParameter_toggled(bool status) +{ + if (status) + { + editfunctionpage->cmdParameter->setEnabled(false); + editfunctionpage->listOfSliders->setEnabled(false); + } +} + +void EditFunction::customMinRange_toggled(bool status) +{ + if (status) + editfunctionpage->min->setEnabled(true); + else + editfunctionpage->min->setEnabled(false); +} + +void EditFunction::customMaxRange_toggled(bool status) +{ + if (status) + editfunctionpage->max->setEnabled(true); + else + editfunctionpage->max->setEnabled(false); +} + +void EditFunction::fixFunctionArguments(QString &f_str) +{ + int const openBracket = f_str.find( "(" ); + int const closeBracket = f_str.find( ")" ); + char parameter_name; + if ( closeBracket-openBracket == 2) //the function atribute is only one character + { + char const function_name = f_str.at(openBracket+1).latin1(); + parameter_name = 'a'; + while ( parameter_name == function_name) + parameter_name++; + } + else + parameter_name = 'a'; + f_str.insert(closeBracket,parameter_name); + f_str.insert(closeBracket,','); +} + diff --git a/kmplot/kmplot/editfunction.h b/kmplot/kmplot/editfunction.h new file mode 100644 index 00000000..9ef8ee05 --- /dev/null +++ b/kmplot/kmplot/editfunction.h @@ -0,0 +1,91 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KEDITFUNCTION_H +#define KEDITFUNCTION_H + +#include <kdialogbase.h> + +#include "xparser.h" + +class XParser; +class EditFunctionPage; +class EditDerivativesPage; +class EditIntegralPage; + +/** @short Dialog window editing a function plot and its properties. */ +class EditFunction : public KDialogBase +{ + Q_OBJECT + public: + /// @param parser points to the parser instance. + /// @param parent points to the parent widget. + /// @param name of this instance. + EditFunction( XParser* parser, QWidget* parent = NULL, const char* name = NULL ); + /// Nothing special to do. + virtual ~EditFunction() {} + /// Fill the dialog's widgets with the properties of the parser function number index. + void initDialog( int id = -1 ); + /// Returns a pointer to the added/updated function + Ufkt *functionItem(); + + protected slots: + /// Overwrites the dialog's accept() method to make sure, that the user's input is valid. + virtual void accept(); + /// Invokes the HelpCenter. + void slotHelp(); + /// Called when the "Change parameter values" is clicked + void cmdParameter_clicked(); + /// Called when the no_parameter-radiobutton is toggled. + void noParameter_toggled(bool); + /// Called when customMinRange is toggled. + void customMinRange_toggled(bool); + /// Called when customMaxRange is toggled. + void customMaxRange_toggled(bool); + + private: + /// Clear alls widgets values + void clearWidgets(); + /// Fill the dialog's widgets with values from the parser + void setWidgets(); + /// Check, if the function has 2 arguments (function group) + bool functionHas2Arguments(); + /// Adding an extra argument + void fixFunctionArguments(QString &); + + /// Pointer to the parser instance + XParser* m_parser; + /// Current function index + int m_id; + QValueList<ParameterValueItem> m_parameter; + + EditFunctionPage* editfunctionpage; + EditDerivativesPage* editderivativespage; + EditIntegralPage* editintegralpage; + + Ufkt *m_updatedfunction; +}; + +#endif diff --git a/kmplot/kmplot/editfunctionpage.ui b/kmplot/kmplot/editfunctionpage.ui new file mode 100644 index 00000000..31d9bd28 --- /dev/null +++ b/kmplot/kmplot/editfunctionpage.ui @@ -0,0 +1,908 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>EditFunctionPage</class> +<widget class="QWidget"> + <property name="name"> + <cstring>EditFunctionPage</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>313</width> + <height>519</height> + </rect> + </property> + <property name="caption"> + <string>Edit Function Plot</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="frameShape"> + <enum>GroupBoxPanel</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="title"> + <string>Definition</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_4</cstring> + </property> + <property name="text"> + <string>&Equation:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>equation</cstring> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>equation</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip" stdset="0"> + <string>enter an equation, for instance f(x)=x^2</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter an equation for the function. +Example: f(x)=x^2</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>buttonGroup1</cstring> + </property> + <property name="title"> + <string>Extensions</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>hide</cstring> + </property> + <property name="text"> + <string>&Hide</string> + </property> + <property name="toolTip" stdset="0"> + <string>hide the plot</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this box if you want to hide the plot of the function.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>parameterValues</cstring> + </property> + <property name="title"> + <string>Parameter Values</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton" row="3" column="0"> + <property name="name"> + <cstring>useSlider</cstring> + </property> + <property name="text"> + <string>Use</string> + </property> + <property name="toolTip" stdset="0"> + <string>change parameter value by moving a slider</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this to change the parameter value by moving a slider. Select the slider from the list box on the right. The values vary from 0 (left) to 100 (right).</string> + </property> + </widget> + <widget class="QComboBox" row="3" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>listOfSliders</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Select a slider</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the sliders to change the parameter value dynamically. The values vary from 0 (left) to 100 (right).</string> + </property> + </widget> + <widget class="QRadioButton" row="2" column="0"> + <property name="name"> + <cstring>useList</cstring> + </property> + <property name="text"> + <string>Values from a list</string> + </property> + <property name="toolTip" stdset="0"> + <string>read parameter values from a list</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this to let KmPlot use parameter values given in a list. Edit this list by clicking the button on the right.</string> + </property> + </widget> + <widget class="KPushButton" row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cmdParameter</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text" stdset="0"> + <string>Edit List...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Edit the list of parameters</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to open a list of parameter values. Here you can add, remove, and change them.</string> + </property> + </widget> + <widget class="QRadioButton" row="0" column="0" rowspan="2" colspan="3"> + <property name="name"> + <cstring>useNoParameter</cstring> + </property> + <property name="text"> + <string>Disable parameter values</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Do not use any parameter values</string> + </property> + <property name="whatsThis" stdset="0"> + <string>By having this option selected parameter values are disabled in the function.</string> + </property> + </widget> + </grid> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>frame5</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>customMinRange</cstring> + </property> + <property name="text"> + <string>Custom plot m&inimum-range:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Customize the minimum plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button and enter the plot range boundarys below.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>&Min:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>min</cstring> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>min</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>lower boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the lower boundary of the plot range. Expressions like 2*pi are allowed, too.</string> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>customMaxRange</cstring> + </property> + <property name="text"> + <string>Custom plot m&aximum-range:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Customize the maximum plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button and enter the plot range boundarys below.</string> + </property> + </widget> + <widget class="KLineEdit" row="3" column="1"> + <property name="name"> + <cstring>max</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>upper boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the upper boundary of the plot range. Expressions like 2*pi are allowed, too.</string> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Ma&x:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>max</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>frame6</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Co&lor:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>color</cstring> + </property> + </widget> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>color</cstring> + </property> + <property name="text" stdset="0"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>color of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to choose a color for the plot line.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="text"> + <string>Line &width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>lineWidth</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>lineWidth</cstring> + </property> + <property name="minValue" stdset="0"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>width of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Change the width of the plot line in steps of 0.1mm.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>0.1mm</string> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer8</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<customwidgets> + <customwidget> + <class>KLineEdit</class> + <header location="local">klineedit.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + <signal>destroyed()</signal> + <signal>destroyed(QObject*)</signal> + <signal>textChanged(const QString&)</signal> + <signal>returnPressed()</signal> + <signal>lostFocus()</signal> + <signal>selectionChanged()</signal> + <signal>completionBoxActivated(const QString&)</signal> + <signal>returnPressed(const QString&)</signal> + <signal>completion(const QString&)</signal> + <signal>substringCompletion(const QString&)</signal> + <signal>textRotation(KCompletionBase::KeyBindingType)</signal> + <signal>completionModeChanged(KGlobalSettings::Completion)</signal> + <signal>aboutToShowContextMenu(QPopupMenu*)</signal> + <slot access="public" specifier="">deleteLater()</slot> + <slot access="private" specifier="">cleanupEventFilter(QObject*)</slot> + <slot access="public" specifier="">setEnabled(bool)</slot> + <slot access="public" specifier="">setDisabled(bool)</slot> + <slot access="public" specifier="">setCaption(const QString&)</slot> + <slot access="public" specifier="">setIcon(const QPixmap&)</slot> + <slot access="public" specifier="">setIconText(const QString&)</slot> + <slot access="public" specifier="">setMouseTracking(bool)</slot> + <slot access="public" specifier="">setFocus()</slot> + <slot access="public" specifier="">clearFocus()</slot> + <slot access="public" specifier="">setUpdatesEnabled(bool)</slot> + <slot access="public" specifier="">update()</slot> + <slot access="public" specifier="">update(int,int,int,int)</slot> + <slot access="public" specifier="">update(const QRect&)</slot> + <slot access="public" specifier="">repaint()</slot> + <slot access="public" specifier="">repaint(bool)</slot> + <slot access="public" specifier="">repaint(int,int,int,int)</slot> + <slot access="public" specifier="">repaint(int,int,int,int,bool)</slot> + <slot access="public" specifier="">repaint(const QRect&)</slot> + <slot access="public" specifier="">repaint(const QRect&,bool)</slot> + <slot access="public" specifier="">repaint(const QRegion&)</slot> + <slot access="public" specifier="">repaint(const QRegion&,bool)</slot> + <slot access="public" specifier="">show()</slot> + <slot access="public" specifier="">hide()</slot> + <slot access="public" specifier="">setShown(bool)</slot> + <slot access="public" specifier="">setHidden(bool)</slot> + <slot access="public" specifier="">iconify()</slot> + <slot access="public" specifier="">showMinimized()</slot> + <slot access="public" specifier="">showMaximized()</slot> + <slot access="public" specifier="">showFullScreen()</slot> + <slot access="public" specifier="">showNormal()</slot> + <slot access="public" specifier="">polish()</slot> + <slot access="public" specifier="">constPolish()</slot> + <slot access="public" specifier="">close()</slot> + <slot access="public" specifier="">raise()</slot> + <slot access="public" specifier="">lower()</slot> + <slot access="public" specifier="">stackUnder(QWidget*)</slot> + <slot access="public" specifier="">move(int,int)</slot> + <slot access="public" specifier="">move(const QPoint&)</slot> + <slot access="public" specifier="">resize(int,int)</slot> + <slot access="public" specifier="">resize(const QSize&)</slot> + <slot access="public" specifier="">setGeometry(int,int,int,int)</slot> + <slot access="public" specifier="">setGeometry(const QRect&)</slot> + <slot access="public" specifier="">adjustSize()</slot> + <slot access="private" specifier="">focusProxyDestroyed()</slot> + <slot access="public" specifier="">setText(const QString&)</slot> + <slot access="public" specifier="">selectAll()</slot> + <slot access="public" specifier="">deselect()</slot> + <slot access="public" specifier="">clearValidator()</slot> + <slot access="public" specifier="">insert(const QString&)</slot> + <slot access="public" specifier="">clear()</slot> + <slot access="public" specifier="">undo()</slot> + <slot access="public" specifier="">redo()</slot> + <slot access="public" specifier="">setMaxLength(int)</slot> + <slot access="public" specifier="">setFrame(bool)</slot> + <slot access="public" specifier="">setEchoMode(EchoMode)</slot> + <slot access="public" specifier="">setReadOnly(bool)</slot> + <slot access="public" specifier="">setValidator(const QValidator*)</slot> + <slot access="public" specifier="">setFont(const QFont&)</slot> + <slot access="public" specifier="">setPalette(const QPalette&)</slot> + <slot access="public" specifier="">setSelection(int,int)</slot> + <slot access="public" specifier="">setCursorPosition(int)</slot> + <slot access="public" specifier="">setAlignment(int)</slot> + <slot access="public" specifier="">cut()</slot> + <slot access="public" specifier="">copy()</slot> + <slot access="public" specifier="">paste()</slot> + <slot access="public" specifier="">setDragEnabled(bool)</slot> + <slot access="private" specifier="">clipboardChanged()</slot> + <slot access="public" specifier="">setReadOnly(bool)</slot> + <slot access="public" specifier="">rotateText(KCompletionBase::KeyBindingType)</slot> + <slot access="public" specifier="">setCompletedText(const QString&)</slot> + <slot access="public" specifier="">setCompletedItems(const QStringList&)</slot> + <slot access="public" specifier="">setCompletedItems(const QStringList&,bool)</slot> + <slot access="public" specifier="">clear()</slot> + <slot access="public" specifier="">setSqueezedText(const QString&)</slot> + <slot access="public" specifier="">setText(const QString&)</slot> + <slot access="protected" specifier="">makeCompletion(const QString&)</slot> + <slot access="protected" specifier="">slotAboutToShow()</slot> + <slot access="protected" specifier="">slotCancelled()</slot> + <slot access="protected" specifier="">userCancelled(const QString&)</slot> + <slot access="private" specifier="">completionMenuActivated(int)</slot> + <slot access="private" specifier="">tripleClickTimeout()</slot> + <slot access="private" specifier="">slotRestoreSelectionColors()</slot> + <slot access="private" specifier="">setTextWorkaround(const QString&)</slot> + <property type="CString">name</property> + <property type="Bool">enabled</property> + <property type="Rect">geometry</property> + <property type="SizePolicy">sizePolicy</property> + <property type="Size">minimumSize</property> + <property type="Size">maximumSize</property> + <property type="Size">sizeIncrement</property> + <property type="Size">baseSize</property> + <property type="Color">paletteForegroundColor</property> + <property type="Color">paletteBackgroundColor</property> + <property type="Pixmap">paletteBackgroundPixmap</property> + <property type="Palette">palette</property> + <property type="BackgroundOrigin">backgroundOrigin</property> + <property type="Font">font</property> + <property type="Cursor">cursor</property> + <property type="String">caption</property> + <property type="Pixmap">icon</property> + <property type="String">iconText</property> + <property type="Bool">mouseTracking</property> + <property type="FocusPolicy">focusPolicy</property> + <property type="Bool">acceptDrops</property> + <property type="Shape">frameShape</property> + <property type="Shadow">frameShadow</property> + <property type="Int">lineWidth</property> + <property type="Int">margin</property> + <property type="Int">midLineWidth</property> + <property type="String">text</property> + <property type="Int">maxLength</property> + <property type="Bool">frame</property> + <property type="EchoMode">echoMode</property> + <property type="Int">cursorPosition</property> + <property type="Alignment">alignment</property> + <property type="Bool">dragEnabled</property> + <property type="Bool">readOnly</property> + <property type="String">inputMask</property> + <property type="Bool">contextMenuEnabled</property> + <property type="Bool">urlDropsEnabled</property> + <property type="Bool">trapEnterKeyEvent</property> + <property type="Bool">enableSqueezedText</property> + </customwidget> + <customwidget> + <class>KColorButton</class> + <header location="local">kcolorbutton.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + <signal>destroyed()</signal> + <signal>destroyed(QObject*)</signal> + <signal>pressed()</signal> + <signal>released()</signal> + <signal>clicked()</signal> + <signal>toggled(bool)</signal> + <signal>stateChanged(int)</signal> + <signal>changed(const QColor&)</signal> + <slot access="public" specifier="">deleteLater()</slot> + <slot access="private" specifier="">cleanupEventFilter(QObject*)</slot> + <slot access="public" specifier="">setEnabled(bool)</slot> + <slot access="public" specifier="">setDisabled(bool)</slot> + <slot access="public" specifier="">setCaption(const QString&)</slot> + <slot access="public" specifier="">setIcon(const QPixmap&)</slot> + <slot access="public" specifier="">setIconText(const QString&)</slot> + <slot access="public" specifier="">setMouseTracking(bool)</slot> + <slot access="public" specifier="">setFocus()</slot> + <slot access="public" specifier="">clearFocus()</slot> + <slot access="public" specifier="">setUpdatesEnabled(bool)</slot> + <slot access="public" specifier="">update()</slot> + <slot access="public" specifier="">update(int,int,int,int)</slot> + <slot access="public" specifier="">update(const QRect&)</slot> + <slot access="public" specifier="">repaint()</slot> + <slot access="public" specifier="">repaint(bool)</slot> + <slot access="public" specifier="">repaint(int,int,int,int)</slot> + <slot access="public" specifier="">repaint(int,int,int,int,bool)</slot> + <slot access="public" specifier="">repaint(const QRect&)</slot> + <slot access="public" specifier="">repaint(const QRect&,bool)</slot> + <slot access="public" specifier="">repaint(const QRegion&)</slot> + <slot access="public" specifier="">repaint(const QRegion&,bool)</slot> + <slot access="public" specifier="">show()</slot> + <slot access="public" specifier="">hide()</slot> + <slot access="public" specifier="">setShown(bool)</slot> + <slot access="public" specifier="">setHidden(bool)</slot> + <slot access="public" specifier="">iconify()</slot> + <slot access="public" specifier="">showMinimized()</slot> + <slot access="public" specifier="">showMaximized()</slot> + <slot access="public" specifier="">showFullScreen()</slot> + <slot access="public" specifier="">showNormal()</slot> + <slot access="public" specifier="">polish()</slot> + <slot access="public" specifier="">constPolish()</slot> + <slot access="public" specifier="">close()</slot> + <slot access="public" specifier="">raise()</slot> + <slot access="public" specifier="">lower()</slot> + <slot access="public" specifier="">stackUnder(QWidget*)</slot> + <slot access="public" specifier="">move(int,int)</slot> + <slot access="public" specifier="">move(const QPoint&)</slot> + <slot access="public" specifier="">resize(int,int)</slot> + <slot access="public" specifier="">resize(const QSize&)</slot> + <slot access="public" specifier="">setGeometry(int,int,int,int)</slot> + <slot access="public" specifier="">setGeometry(const QRect&)</slot> + <slot access="public" specifier="">adjustSize()</slot> + <slot access="private" specifier="">focusProxyDestroyed()</slot> + <slot access="public" specifier="">animateClick()</slot> + <slot access="public" specifier="">toggle()</slot> + <slot access="private" specifier="">animateTimeout()</slot> + <slot access="private" specifier="">autoRepeatTimeout()</slot> + <slot access="private" specifier="">emulateClick()</slot> + <slot access="public" specifier="">setOn(bool)</slot> + <slot access="private" specifier="">popupPressed()</slot> + <slot access="protected" specifier="">chooseColor()</slot> + <property type="CString">name</property> + <property type="Bool">enabled</property> + <property type="Rect">geometry</property> + <property type="SizePolicy">sizePolicy</property> + <property type="Size">minimumSize</property> + <property type="Size">maximumSize</property> + <property type="Size">sizeIncrement</property> + <property type="Size">baseSize</property> + <property type="Color">paletteForegroundColor</property> + <property type="Color">paletteBackgroundColor</property> + <property type="Pixmap">paletteBackgroundPixmap</property> + <property type="Palette">palette</property> + <property type="BackgroundOrigin">backgroundOrigin</property> + <property type="Font">font</property> + <property type="Cursor">cursor</property> + <property type="String">caption</property> + <property type="Pixmap">icon</property> + <property type="String">iconText</property> + <property type="Bool">mouseTracking</property> + <property type="FocusPolicy">focusPolicy</property> + <property type="Bool">acceptDrops</property> + <property type="String">text</property> + <property type="Pixmap">pixmap</property> + <property type="KeySequence">accel</property> + <property type="Bool">autoRepeat</property> + <property type="Bool">autoDefault</property> + <property type="Bool">default</property> + <property type="IconSet">iconSet</property> + <property type="Bool">toggleButton</property> + <property type="Bool">on</property> + <property type="Bool">flat</property> + <property type="Bool">autoMask</property> + <property type="Color">color</property> + </customwidget> + <customwidget> + <class>KIntNumInput</class> + <header location="local">knuminput.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + <signal>destroyed()</signal> + <signal>destroyed(QObject*)</signal> + <signal>valueChanged(int)</signal> + <signal>relativeValueChanged(double)</signal> + <slot access="public" specifier="">deleteLater()</slot> + <slot access="private" specifier="">cleanupEventFilter(QObject*)</slot> + <slot access="public" specifier="">setEnabled(bool)</slot> + <slot access="public" specifier="">setDisabled(bool)</slot> + <slot access="public" specifier="">setCaption(const QString&)</slot> + <slot access="public" specifier="">setIcon(const QPixmap&)</slot> + <slot access="public" specifier="">setIconText(const QString&)</slot> + <slot access="public" specifier="">setMouseTracking(bool)</slot> + <slot access="public" specifier="">setFocus()</slot> + <slot access="public" specifier="">clearFocus()</slot> + <slot access="public" specifier="">setUpdatesEnabled(bool)</slot> + <slot access="public" specifier="">update()</slot> + <slot access="public" specifier="">update(int,int,int,int)</slot> + <slot access="public" specifier="">update(const QRect&)</slot> + <slot access="public" specifier="">repaint()</slot> + <slot access="public" specifier="">repaint(bool)</slot> + <slot access="public" specifier="">repaint(int,int,int,int)</slot> + <slot access="public" specifier="">repaint(int,int,int,int,bool)</slot> + <slot access="public" specifier="">repaint(const QRect&)</slot> + <slot access="public" specifier="">repaint(const QRect&,bool)</slot> + <slot access="public" specifier="">repaint(const QRegion&)</slot> + <slot access="public" specifier="">repaint(const QRegion&,bool)</slot> + <slot access="public" specifier="">show()</slot> + <slot access="public" specifier="">hide()</slot> + <slot access="public" specifier="">setShown(bool)</slot> + <slot access="public" specifier="">setHidden(bool)</slot> + <slot access="public" specifier="">iconify()</slot> + <slot access="public" specifier="">showMinimized()</slot> + <slot access="public" specifier="">showMaximized()</slot> + <slot access="public" specifier="">showFullScreen()</slot> + <slot access="public" specifier="">showNormal()</slot> + <slot access="public" specifier="">polish()</slot> + <slot access="public" specifier="">constPolish()</slot> + <slot access="public" specifier="">close()</slot> + <slot access="public" specifier="">raise()</slot> + <slot access="public" specifier="">lower()</slot> + <slot access="public" specifier="">stackUnder(QWidget*)</slot> + <slot access="public" specifier="">move(int,int)</slot> + <slot access="public" specifier="">move(const QPoint&)</slot> + <slot access="public" specifier="">resize(int,int)</slot> + <slot access="public" specifier="">resize(const QSize&)</slot> + <slot access="public" specifier="">setGeometry(int,int,int,int)</slot> + <slot access="public" specifier="">setGeometry(const QRect&)</slot> + <slot access="public" specifier="">adjustSize()</slot> + <slot access="private" specifier="">focusProxyDestroyed()</slot> + <slot access="public" specifier="">setValue(int)</slot> + <slot access="public" specifier="">setRelativeValue(double)</slot> + <slot access="public" specifier="">setReferencePoint(int)</slot> + <slot access="public" specifier="">setSuffix(const QString&)</slot> + <slot access="public" specifier="">setPrefix(const QString&)</slot> + <slot access="public" specifier="">setEditFocus()</slot> + <slot access="public" specifier="">setEditFocus(bool)</slot> + <slot access="private" specifier="">spinValueChanged(int)</slot> + <slot access="private" specifier="">slotEmitRelativeValueChanged(int)</slot> + <property type="CString">name</property> + <property type="Bool">enabled</property> + <property type="Rect">geometry</property> + <property type="SizePolicy">sizePolicy</property> + <property type="Size">minimumSize</property> + <property type="Size">maximumSize</property> + <property type="Size">sizeIncrement</property> + <property type="Size">baseSize</property> + <property type="Color">paletteForegroundColor</property> + <property type="Color">paletteBackgroundColor</property> + <property type="Pixmap">paletteBackgroundPixmap</property> + <property type="Palette">palette</property> + <property type="BackgroundOrigin">backgroundOrigin</property> + <property type="Font">font</property> + <property type="Cursor">cursor</property> + <property type="String">caption</property> + <property type="Pixmap">icon</property> + <property type="String">iconText</property> + <property type="Bool">mouseTracking</property> + <property type="FocusPolicy">focusPolicy</property> + <property type="Bool">acceptDrops</property> + <property type="String">label</property> + <property type="Int">value</property> + <property type="Int">minValue</property> + <property type="Int">maxValue</property> + <property type="Int">referencePoint</property> + <property type="String">suffix</property> + <property type="String">prefix</property> + <property type="String">specialValueText</property> + </customwidget> + <customwidget> + <class>KPushButton</class> + <header location="local">kpushbutton.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + <signal>destroyed()</signal> + <signal>destroyed(QObject*)</signal> + <signal>pressed()</signal> + <signal>released()</signal> + <signal>clicked()</signal> + <signal>toggled(bool)</signal> + <signal>stateChanged(int)</signal> + <slot access="public" specifier="">deleteLater()</slot> + <slot access="private" specifier="">cleanupEventFilter(QObject*)</slot> + <slot access="public" specifier="">setEnabled(bool)</slot> + <slot access="public" specifier="">setDisabled(bool)</slot> + <slot access="public" specifier="">setCaption(const QString&)</slot> + <slot access="public" specifier="">setIcon(const QPixmap&)</slot> + <slot access="public" specifier="">setIconText(const QString&)</slot> + <slot access="public" specifier="">setMouseTracking(bool)</slot> + <slot access="public" specifier="">setFocus()</slot> + <slot access="public" specifier="">clearFocus()</slot> + <slot access="public" specifier="">setUpdatesEnabled(bool)</slot> + <slot access="public" specifier="">update()</slot> + <slot access="public" specifier="">update(int,int,int,int)</slot> + <slot access="public" specifier="">update(const QRect&)</slot> + <slot access="public" specifier="">repaint()</slot> + <slot access="public" specifier="">repaint(bool)</slot> + <slot access="public" specifier="">repaint(int,int,int,int)</slot> + <slot access="public" specifier="">repaint(int,int,int,int,bool)</slot> + <slot access="public" specifier="">repaint(const QRect&)</slot> + <slot access="public" specifier="">repaint(const QRect&,bool)</slot> + <slot access="public" specifier="">repaint(const QRegion&)</slot> + <slot access="public" specifier="">repaint(const QRegion&,bool)</slot> + <slot access="public" specifier="">show()</slot> + <slot access="public" specifier="">hide()</slot> + <slot access="public" specifier="">setShown(bool)</slot> + <slot access="public" specifier="">setHidden(bool)</slot> + <slot access="public" specifier="">iconify()</slot> + <slot access="public" specifier="">showMinimized()</slot> + <slot access="public" specifier="">showMaximized()</slot> + <slot access="public" specifier="">showFullScreen()</slot> + <slot access="public" specifier="">showNormal()</slot> + <slot access="public" specifier="">polish()</slot> + <slot access="public" specifier="">constPolish()</slot> + <slot access="public" specifier="">close()</slot> + <slot access="public" specifier="">raise()</slot> + <slot access="public" specifier="">lower()</slot> + <slot access="public" specifier="">stackUnder(QWidget*)</slot> + <slot access="public" specifier="">move(int,int)</slot> + <slot access="public" specifier="">move(const QPoint&)</slot> + <slot access="public" specifier="">resize(int,int)</slot> + <slot access="public" specifier="">resize(const QSize&)</slot> + <slot access="public" specifier="">setGeometry(int,int,int,int)</slot> + <slot access="public" specifier="">setGeometry(const QRect&)</slot> + <slot access="public" specifier="">adjustSize()</slot> + <slot access="private" specifier="">focusProxyDestroyed()</slot> + <slot access="public" specifier="">animateClick()</slot> + <slot access="public" specifier="">toggle()</slot> + <slot access="private" specifier="">animateTimeout()</slot> + <slot access="private" specifier="">autoRepeatTimeout()</slot> + <slot access="private" specifier="">emulateClick()</slot> + <slot access="public" specifier="">setOn(bool)</slot> + <slot access="private" specifier="">popupPressed()</slot> + <slot access="private" specifier="">slotSettingsChanged(int)</slot> + <property type="CString">name</property> + <property type="Bool">enabled</property> + <property type="Rect">geometry</property> + <property type="SizePolicy">sizePolicy</property> + <property type="Size">minimumSize</property> + <property type="Size">maximumSize</property> + <property type="Size">sizeIncrement</property> + <property type="Size">baseSize</property> + <property type="Color">paletteForegroundColor</property> + <property type="Color">paletteBackgroundColor</property> + <property type="Pixmap">paletteBackgroundPixmap</property> + <property type="Palette">palette</property> + <property type="BackgroundOrigin">backgroundOrigin</property> + <property type="Font">font</property> + <property type="Cursor">cursor</property> + <property type="String">caption</property> + <property type="Pixmap">icon</property> + <property type="String">iconText</property> + <property type="Bool">mouseTracking</property> + <property type="FocusPolicy">focusPolicy</property> + <property type="Bool">acceptDrops</property> + <property type="String">text</property> + <property type="Pixmap">pixmap</property> + <property type="KeySequence">accel</property> + <property type="Bool">autoRepeat</property> + <property type="Bool">autoDefault</property> + <property type="Bool">default</property> + <property type="IconSet">iconSet</property> + <property type="Bool">toggleButton</property> + <property type="Bool">on</property> + <property type="Bool">flat</property> + <property type="Bool">autoMask</property> + </customwidget> +</customwidgets> +<images> + <image name="image0"> + <data format="PNG" length="826">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b00000301494441541895b59531681b5718c77f0e377c070e3c810a3a70e0041eac51852e0a19e45134830a1d9a4c69a04bc8928e990a693a640e1d0c8642b08742321894c1507991b484c890902bb8701a047760c3bd21701fe4201dde49b6a41a32b8df72dcbbeffdbefffbbfefbd5b1b0c07cce266ebe667ae2006c3c1dada0cdc3be87d6e6c35b0d692a409d9c7ec8b20d65ae29398d19b1114e7e3de4ce98b3f5e10dc0053cf0951b4506496e1b964bf7ce6c585d9054c62d01d617ca48be0596553cf496d8f2c8b01c5f795fc93904e85ec4c01a152857a5d9175d0b2805c872080f18595ccc1499a10a225d4e2fbc2877786fe81253ab6c04c8d106e09db5d43ab0d146e5c64d1a23938fb98a185cea1c33eecfd9eba49eb427dcb201e245365f2b7b2fb5b4a3a31dcb927178afe07d86901df870fefa4842aed6f6b74ba42e52b4014d580e1eb9cbd9d94de7e4aad16d2f9be02d805f0b5e532f927a1ffcacea1777f122a8105b164a7c25faf323a5d9f1f1fd600e1e5bec59e2d4b5c7ef5209d0ad17b8b31864e57c0b3e0815ac3ee33253ab664a770ff5185d1a1cb8d2267d3e58aa1dc7d2508cbe597d0e74fdd269aaaf0f52d414c4ea3e9762c996869e42560d7a72e41c4799a2586e74f95e8d8151481fa86efbe7b3398ac58b1a2b8527589f15451ad303ac2293542ad6648a796278f13a27185e4c4754310facb98c53a79e19a3fdc1426ff28c3d7399d1f7cb25343eb96106cf83c790ce9c4f2eb831855c55485663327992eb6dc8a6259874ed700b0b793323cccb9ffa842b30d6133e3e75fea989ac15a8b16ca76b746b0b92278d919774c5b6d48a78697fb29bbcf52468742a32120909c24e899ce67beed5be2db01e22d1e9485bb620e47f9ee9e606a21bd3f5d3744c7e7c54d55e87443867d8b554515ac5db4620e8e4f62263170fd1cdee90aad7640141992891b0f367c9adfe4049bb07d3b7022bd8c687c0978f46684ee084150b65ac1fcca94591b7a90a496e4c095164fb016a2b192a497795cc0f84817aebe25f7bf70ccc54a575c555c03f78ffa5fc0570d1f0c076bff0232285a09283782c80000000049454e44ae426082</data> + </image> +</images> +<connections> + <connection> + <sender>useList</sender> + <signal>toggled(bool)</signal> + <receiver>cmdParameter</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>useList</sender> + <signal>toggled(bool)</signal> + <receiver>listOfSliders</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>useSlider</sender> + <signal>toggled(bool)</signal> + <receiver>cmdParameter</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>useSlider</sender> + <signal>toggled(bool)</signal> + <receiver>listOfSliders</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>equation</tabstop> + <tabstop>hide</tabstop> + <tabstop>useList</tabstop> + <tabstop>cmdParameter</tabstop> + <tabstop>listOfSliders</tabstop> + <tabstop>customMinRange</tabstop> + <tabstop>min</tabstop> + <tabstop>max</tabstop> + <tabstop>lineWidth</tabstop> + <tabstop>color</tabstop> +</tabstops> +<slots> + <slot>slotHelp()</slot> + <slot>customRange_toggled( bool )</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kcolorbutton.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/editintegralpage.ui b/kmplot/kmplot/editintegralpage.ui new file mode 100644 index 00000000..5180a8d2 --- /dev/null +++ b/kmplot/kmplot/editintegralpage.ui @@ -0,0 +1,288 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>EditIntegralPage</class> +<widget class="QWidget"> + <property name="name"> + <cstring>EditIntegralPage</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>324</width> + <height>316</height> + </rect> + </property> + <property name="caption"> + <string>Integral</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>showIntegral</cstring> + </property> + <property name="text"> + <string>Show integral</string> + </property> + <property name="toolTip" stdset="0"> + <string>hide the plot</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this box if you want to hide the plot of the function.</string> + </property> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>grpPoint</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="title"> + <string>Initial Point</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_5</cstring> + </property> + <property name="text"> + <string>&x-value:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>txtInitX</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_5_2</cstring> + </property> + <property name="text"> + <string>&y-value:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>txtInitY</cstring> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>txtInitX</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>Enter the initial x-point,for instance 2 or pi</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the initial x-value or expression for the integral, for example 2 or pi/2</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>txtInitY</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>enter the initial y-point, eg 2 or pi</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the initial y-value or expression for the integral, for example 2 or pi/2</string> + </property> + </widget> + </grid> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>frame5_2_2</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2_2_3</cstring> + </property> + <property name="text"> + <string>P&recision:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>precision</cstring> + </property> + </widget> + <widget class="KDoubleNumInput" row="1" column="1"> + <property name="name"> + <cstring>precision</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minValue"> + <number>0.01</number> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>customPrecision</cstring> + </property> + <property name="text"> + <string>Custom &precision</string> + </property> + <property name="toolTip" stdset="0"> + <string>Customize the precision</string> + </property> + </widget> + </grid> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>frame6_3</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2_3</cstring> + </property> + <property name="text"> + <string>Color:</string> + </property> + </widget> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>color</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>color of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to choose a color for the plot line.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_3_3</cstring> + </property> + <property name="text"> + <string>Line width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>lineWidthAntiderivative</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>lineWidth</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>width of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Change the width of the plot line in steps of 0.1mm.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>TextLabel2_3</cstring> + </property> + <property name="text"> + <string>0.1mm</string> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>62</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>showIntegral</sender> + <signal>toggled(bool)</signal> + <receiver>grpPoint</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>showIntegral</sender> + <signal>toggled(bool)</signal> + <receiver>frame5_2_2</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>showIntegral</sender> + <signal>toggled(bool)</signal> + <receiver>frame6_3</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>customPrecision</sender> + <signal>toggled(bool)</signal> + <receiver>precision</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>customPrecision</sender> + <signal>toggled(bool)</signal> + <receiver>textLabel2_2_3</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>showIntegral</tabstop> + <tabstop>txtInitX</tabstop> + <tabstop>txtInitY</tabstop> + <tabstop>customPrecision</tabstop> + <tabstop>precision</tabstop> + <tabstop>lineWidth</tabstop> + <tabstop>color</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/kconstanteditor.cpp b/kmplot/kmplot/kconstanteditor.cpp new file mode 100644 index 00000000..6014c82b --- /dev/null +++ b/kmplot/kmplot/kconstanteditor.cpp @@ -0,0 +1,215 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include <kapplication.h> +#include <kdebug.h> +#include <kinputdialog.h> +#include <klineedit.h> +#include <klistview.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <qpushbutton.h> +#include <qstringlist.h> +#include <qvaluevector.h> +#include <qdom.h> + +#include "kmplotio.h" +#include "kconstanteditor.h" + + +KConstantEditor::KConstantEditor(View *v, QWidget *parent, const char *name) + : QConstantEditor(parent,name), m_view(v) +{ + QString str_value; + QValueVector<Constant>::iterator it; + for(it = m_view->parser()->constant.begin(); it!= m_view->parser()->constant.end() ;++it) + { + str_value.setNum(it->value); + (void) new QListViewItem(varlist, QChar(it->constant), str_value); + } + +} + +KConstantEditor::~KConstantEditor() +{ +} + +void KConstantEditor::cmdNew_clicked() +{ + constant = '0'; + KEditConstant *dlg = new KEditConstant(m_view->parser(), constant, value); + connect( dlg, SIGNAL( finished() ), this,SLOT(newConstantSlot() ) ); + dlg->show(); +} + +void KConstantEditor::cmdEdit_clicked() +{ + if ( !varlist->currentItem() ) + return; + constant = varlist->currentItem()->text(0).at(0).latin1(); + value = varlist->currentItem()->text(1); + + KEditConstant *dlg = new KEditConstant(m_view->parser(), constant, value); + connect( dlg, SIGNAL( finished() ), this,SLOT(editConstantSlot() ) ); + dlg->show(); +} + +void KConstantEditor::cmdDelete_clicked() +{ + if ( !varlist->currentItem() ) + return; + + constant = varlist->currentItem()->text(0).at(0).latin1(); + value = varlist->currentItem()->text(1); + QString str; + + for( QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it != m_view->parser()->ufkt.end(); ++it) + { + str = it->fstr; + for (int i=str.find(')'); (uint)i<str.length();i++) + if ( str.at(i) == constant ) + { + KMessageBox::error(this, i18n("A function uses this constant; therefore, it cannot be removed.")); + return; + } + } + QValueVector<Constant>::iterator it; + for(it = m_view->parser()->constant.begin(); it!= m_view->parser()->constant.end(); ++it) + { + if ( it->constant == constant) + { + if ( it++ == m_view->parser()->constant.end()) + m_view->parser()->constant.pop_back(); + else + { + it--; + m_view->parser()->constant.erase(it++); + } + KMessageBox::error(this, i18n("The item could not be found.")); + return; + } + } + + delete varlist->findItem(QChar(constant), 0); //removes the item from the constant list +} + +void KConstantEditor::varlist_clicked( QListViewItem * item ) +{ + if (item) + { + cmdEdit->setEnabled(true); + cmdDelete->setEnabled(true); + cmdDuplicate->setEnabled(true); + } + else + { + cmdEdit->setEnabled(false); + cmdDelete->setEnabled(false); + cmdDuplicate->setEnabled(false); + } +} + +void KConstantEditor::cmdDuplicate_clicked() +{ + if (!varlist->currentItem()) + return; + constant = varlist->currentItem()->text(0).at(0).latin1(); + value = varlist->currentItem()->text(1); + + QStringList list; + bool found; + for (char i='A'; i<'Z';i++) + { + found = false; + QValueVector<Constant>::iterator it; + for(it = m_view->parser()->constant.begin(); it!= m_view->parser()->constant.end() && !found;++it) + { + if ( it->constant == i || i == constant) + { + found = true; + } + } + if (!found) + list.append(QChar(i)); + } + QStringList result = KInputDialog::getItemList(i18n("Choose Name"),i18n("Choose a name for the constant:"),list, QStringList(), false, &found); + if (found) + { + constant = (*result.begin()).at(0).latin1(); + emit newConstantSlot(); + } + +} + +void KConstantEditor::newConstantSlot() +{ + double dvalue = m_view->parser()->eval(value); + m_view->parser()->constant.append( Constant(constant, dvalue) ); + (void) new QListViewItem(varlist, QChar( constant ), value); + varlist->sort(); +} + +void KConstantEditor::editConstantSlot() +{ + double dvalue = m_view->parser()->eval(value); + bool found = false; + QValueVector<Constant>::iterator it; + for(it = m_view->parser()->constant.begin(); it!= m_view->parser()->constant.end() && !found;++it) + { + if ( it->constant == constant) + { + it->value = dvalue; + found = true; + } + } + if (!found) + { + KMessageBox::error(this, i18n("The item could not be found.")); + return; + } + + QListViewItem *item = varlist->findItem(QChar(constant), 0); + if (item!=0) + item->setText(1,value); + + + int index = 0; + for( QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it != m_view->parser()->ufkt.end(); ++it) + { + if( it->fstr.contains(constant)!=0 ) + m_view->parser()->reparse(index); //reparsing the function + ++index; + } + + m_view->drawPlot(); +} + +void KConstantEditor::varlist_doubleClicked( QListViewItem * ) +{ + cmdEdit_clicked(); +} + +#include "kconstanteditor.moc" diff --git a/kmplot/kmplot/kconstanteditor.h b/kmplot/kmplot/kconstanteditor.h new file mode 100644 index 00000000..5f801891 --- /dev/null +++ b/kmplot/kmplot/kconstanteditor.h @@ -0,0 +1,68 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KCONSTANTEDITOR_H +#define KCONSTANTEDITOR_H + +#include "qconstanteditor.h" +#include "keditconstant.h" +#include "View.h" + +/** +@author Fredrik Edemar +*/ +/// Handles all the constants. +class KConstantEditor : public QConstantEditor +{ +Q_OBJECT +public: + KConstantEditor(View *, QWidget *parent = 0, const char *name = 0); + ~KConstantEditor(); + +public slots: + /// actions for the buttons + void cmdNew_clicked(); + void cmdEdit_clicked(); + void cmdDelete_clicked(); + void cmdDuplicate_clicked(); + + ///actions for the visible constant list + void varlist_clicked( QListViewItem * item ); + void varlist_doubleClicked( QListViewItem * ); + + /// called when a user pressed OK the the new-constant-dialog + void newConstantSlot(); + /// called when a user pressed OK the the edit-constant-dialog + void editConstantSlot(); + + +private: + char constant; + QString value; + View *m_view; + +}; + +#endif diff --git a/kmplot/kmplot/keditconstant.cpp b/kmplot/kmplot/keditconstant.cpp new file mode 100644 index 00000000..e7a724ac --- /dev/null +++ b/kmplot/kmplot/keditconstant.cpp @@ -0,0 +1,100 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include <kdebug.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <qpushbutton.h> + + +#include "keditconstant.h" + +KEditConstant::KEditConstant(XParser *p, char &c, QString &v, QWidget *parent, const char *name) + : QEditConstant(parent, name,Qt::WDestructiveClose), constant(c), value(v), m_parser(p) +{ + if ( constant != '0' ) + { + txtConstant->setEnabled(false); + txtConstant->setText(QChar(constant)); + txtValue->setText(value); + txtValue->setFocus(); + txtValue->selectAll(); + } + connect( cmdCancel, SIGNAL( clicked() ), this, SLOT( deleteLater() )); + connect( cmdOK, SIGNAL( clicked() ), this, SLOT( cmdOK_clicked() )); +} + + +KEditConstant::~KEditConstant() +{ +} + +void KEditConstant::cmdOK_clicked() +{ + constant = txtConstant->text().at(0).latin1(); + value = txtValue->text(); + if ( constant<'A' || constant>'Z') + { + KMessageBox::error(this, i18n("Please insert a valid constant name between A and Z.")); + txtConstant->setFocus(); + txtConstant->selectAll(); + return; + } + + if ( txtConstant->isEnabled() ) //creating, not edit a constant + { + bool found= false; + QValueVector<Constant>::iterator it; + for(it = m_parser->constant.begin(); it!= m_parser->constant.end() && !found;++it) + { + if ( it->constant == constant) + found = true; + } + if (found) + { + KMessageBox::error(this, i18n("The constant already exists.")); + return; + } + } + (double) m_parser->eval(value); + if ( m_parser->parserError() ) + { + txtValue->setFocus(); + txtValue->selectAll(); + return; + } + + emit finished(); + QDialog::accept(); +} + +void KEditConstant::txtVariable_lostFocus() +{ + txtConstant->setText( txtConstant->text().upper() ); +} + +#include "keditconstant.moc" + diff --git a/kmplot/kmplot/keditconstant.h b/kmplot/kmplot/keditconstant.h new file mode 100644 index 00000000..dcce75cd --- /dev/null +++ b/kmplot/kmplot/keditconstant.h @@ -0,0 +1,60 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KEDITCONSTANT_H +#define KEDITCONSTANT_H + +#include "qeditconstant.h" +#include "xparser.h" + +/** +@author Fredrik Edemar +*/ +/// A small dialog for creating an editing constants +class KEditConstant : public QEditConstant +{ +Q_OBJECT +public: + KEditConstant(XParser *p, char &, QString &,QWidget *parent = 0, const char *name = 0); + ~KEditConstant(); + +public slots: + void cmdOK_clicked(); + void txtVariable_lostFocus(); + +signals: + /// called when we are finished + void finished(); + +private: + char &constant; + QString &value; + XParser *m_parser; + + +}; + +#endif + diff --git a/kmplot/kmplot/keditparametric.cpp b/kmplot/kmplot/keditparametric.cpp new file mode 100644 index 00000000..06b9d359 --- /dev/null +++ b/kmplot/kmplot/keditparametric.cpp @@ -0,0 +1,345 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ +// Qt includes +#include <qcheckbox.h> + +// KDE includes +#include <kapplication.h> +#include <kcolorbutton.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <knuminput.h> + +#include <kdebug.h> + +// local includes +#include "keditparametric.h" +#include "keditparametric.moc" +#include "xparser.h" +#include "View.h" + +KEditParametric::KEditParametric( XParser* parser, QWidget* parent, const char* name ) : + QEditParametric( parent, name ), m_parser(parser) +{ + connect( customMinRange, SIGNAL ( toggled(bool) ), this, SLOT( customMinRange_toggled(bool) ) ); + connect( customMaxRange, SIGNAL ( toggled(bool) ), this, SLOT( customMaxRange_toggled(bool) ) ); + m_updatedfunction = 0; +} + +void KEditParametric::initDialog( int x_id, int y_id) +{ + m_x_id = x_id; + m_y_id = y_id; + if( m_x_id == -1 ) clearWidgets(); + else setWidgets(); +} + +void KEditParametric::clearWidgets() +{ + kLineEditName->clear(); + kLineEditXFunction->clear(); + kLineEditYFunction->clear(); + checkBoxHide->setChecked( false ); + customMinRange->setChecked( false ); + customMinRange->setChecked( false ); + min->clear(); + max->clear(); + kIntNumInputLineWidth->setValue( m_parser->linewidth0 ); + kColorButtonColor->setColor( m_parser->defaultColor(m_parser->getNextIndex() ) ); +} + +void KEditParametric::setWidgets() +{ + Ufkt *ufkt = &m_parser->ufkt[ m_parser->ixValue(m_x_id) ]; + QString name, expression; + splitEquation( ufkt->fstr, name, expression ); + kLineEditName->setText( name ); + kLineEditXFunction->setText( expression ); + splitEquation( m_parser->ufkt[ m_y_id ].fstr, name, expression ); + kLineEditYFunction->setText( expression ); + checkBoxHide->setChecked( !ufkt->f_mode ); + if (ufkt->usecustomxmin) + { + customMinRange->setChecked(true); + min->setText( ufkt->str_dmin ); + } + else + customMinRange->setChecked(false); + + if (ufkt->usecustomxmax) + { + customMaxRange->setChecked(true); + max->setText( ufkt->str_dmax ); + } + else + customMaxRange->setChecked(false); + + kIntNumInputLineWidth->setValue( ufkt->linewidth ); + kColorButtonColor->setColor( ufkt->color ); +} + +void KEditParametric::accept() +{ + if ( kLineEditXFunction->text().contains('y') != 0 || kLineEditYFunction->text().contains('y') != 0) + { + KMessageBox::error( this, i18n( "Recursive function not allowed")); + kLineEditXFunction->setFocus(); + kLineEditXFunction->selectAll(); + return; + } + + // find a name not already used + if( kLineEditName->text().isEmpty() ) + { + QString fname; + m_parser->fixFunctionName(fname, XParser::ParametricX, m_x_id); + int const pos = fname.find('('); + kLineEditName->setText(fname.mid(1,pos-1)); + } + + Ufkt tmp_ufkt; + tmp_ufkt.f_mode = !checkBoxHide->isChecked(); + + if( customMinRange->isChecked() ) + { + tmp_ufkt.usecustomxmin = true; + tmp_ufkt.str_dmin = min->text(); + tmp_ufkt.dmin = m_parser->eval( min->text() ); + if ( m_parser->parserError()) + { + min->setFocus(); + min->selectAll(); + return; + } + } + else + tmp_ufkt.usecustomxmin = false; + + if( customMaxRange->isChecked() ) + { + tmp_ufkt.usecustomxmax = true; + tmp_ufkt.str_dmax = max->text(); + tmp_ufkt.dmax = m_parser->eval( max->text() ); + if ( m_parser->parserError()) + { + max->setFocus(); + max->selectAll(); + return; + } + if ( tmp_ufkt.usecustomxmin && tmp_ufkt.dmin >= tmp_ufkt.dmax) + { + KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value")); + min->setFocus(); + min->selectAll(); + return; + } + } + else + tmp_ufkt.usecustomxmax = false; + + tmp_ufkt.linewidth = kIntNumInputLineWidth->value(); + tmp_ufkt.color = kColorButtonColor->color().rgb(); + tmp_ufkt.f1_color = tmp_ufkt.f2_color = tmp_ufkt.integral_color = tmp_ufkt.color; + tmp_ufkt.integral_mode = 0; + tmp_ufkt.f1_mode = tmp_ufkt.f1_mode; + tmp_ufkt.f2_mode = 0; + tmp_ufkt.use_slider = -1; + + Ufkt *added_ufkt; + if( m_x_id != -1 ) //when editing a function: + { + int const ix = m_parser->ixValue(m_x_id); + if ( ix == -1) //The function could have been deleted + { + KMessageBox::error(this,i18n("Function could not be found")); + return; + } + added_ufkt = &m_parser->ufkt[ix]; + QString old_fstr = added_ufkt->fstr; + added_ufkt->fstr = xFunction(); + m_parser->reparse(added_ufkt); //reparse the funcion + if ( m_parser->parserError() != 0) + { + added_ufkt->fstr = old_fstr; + m_parser->reparse(added_ufkt); + raise(); + kLineEditXFunction->setFocus(); + kLineEditXFunction->selectAll(); + return; + } + } + else + { + int const id = m_parser->addfkt( xFunction() ); + if( id == -1 ) + { + m_parser->parserError(); + raise(); + kLineEditXFunction->setFocus(); + kLineEditXFunction->selectAll(); + return; + } + added_ufkt = &m_parser->ufkt.last(); + } + + //save all settings in the function now when we know no errors have appeared + added_ufkt->f_mode = tmp_ufkt.f_mode; + added_ufkt->f1_mode = tmp_ufkt.f1_mode; + added_ufkt->f2_mode = tmp_ufkt.f2_mode; + added_ufkt->integral_mode = tmp_ufkt.integral_mode; + added_ufkt->integral_use_precision = tmp_ufkt.integral_use_precision; + added_ufkt->linewidth = tmp_ufkt.linewidth; + added_ufkt->f1_linewidth = tmp_ufkt.f1_linewidth; + added_ufkt->f2_linewidth = tmp_ufkt.f2_linewidth; + added_ufkt->integral_linewidth = tmp_ufkt.integral_linewidth; + added_ufkt->str_dmin = tmp_ufkt.str_dmin; + added_ufkt->str_dmax = tmp_ufkt.str_dmax; + added_ufkt->dmin = tmp_ufkt.dmin; + added_ufkt->dmax = tmp_ufkt.dmax; + added_ufkt->str_startx = tmp_ufkt.str_startx; + added_ufkt->str_starty = tmp_ufkt.str_starty; + added_ufkt->oldx = tmp_ufkt.oldx; + added_ufkt->starty = tmp_ufkt.starty; + added_ufkt->startx = tmp_ufkt.startx; + added_ufkt->integral_precision = tmp_ufkt.integral_precision; + added_ufkt->color = tmp_ufkt.color; + added_ufkt->f1_color = tmp_ufkt.f1_color; + added_ufkt->f2_color = tmp_ufkt.f2_color; + added_ufkt->integral_color = tmp_ufkt.integral_color; + added_ufkt->use_slider = tmp_ufkt.use_slider; + added_ufkt->usecustomxmin = tmp_ufkt.usecustomxmin; + added_ufkt->usecustomxmax = tmp_ufkt.usecustomxmax; + + added_ufkt = 0; + if( m_y_id != -1 ) //when editing a function: + { + added_ufkt = &m_parser->ufkt[m_parser->ixValue(m_y_id)]; + QString old_fstr = added_ufkt->fstr; + added_ufkt->fstr = yFunction(); + m_parser->reparse(added_ufkt); //reparse the funcion + if ( m_parser->parserError() != 0) //when something went wrong: + { + added_ufkt->fstr = old_fstr; //go back to the old expression + m_parser->reparse(added_ufkt); //reparse + raise(); + kLineEditXFunction->setFocus(); + kLineEditXFunction->selectAll(); + return; + } + } + else + { + int const id = m_parser->addfkt( yFunction() ); + if( id == -1 ) + { + m_parser->parserError(); + raise(); + kLineEditXFunction->setFocus(); + kLineEditXFunction->selectAll(); + return; + } + added_ufkt = &m_parser->ufkt.last(); + } + + //save all settings in the function now when we now no errors have appeared + added_ufkt->f_mode = tmp_ufkt.f_mode; + added_ufkt->f1_mode = tmp_ufkt.f1_mode; + added_ufkt->f2_mode = tmp_ufkt.f2_mode; + added_ufkt->integral_mode = tmp_ufkt.integral_mode; + added_ufkt->integral_use_precision = tmp_ufkt.integral_use_precision; + added_ufkt->linewidth = tmp_ufkt.linewidth; + added_ufkt->f1_linewidth = tmp_ufkt.f1_linewidth; + added_ufkt->f2_linewidth = tmp_ufkt.f2_linewidth; + added_ufkt->integral_linewidth = tmp_ufkt.integral_linewidth; + added_ufkt->str_dmin = tmp_ufkt.str_dmin; + added_ufkt->str_dmax = tmp_ufkt.str_dmax; + added_ufkt->dmin = tmp_ufkt.dmin; + added_ufkt->dmax = tmp_ufkt.dmax; + added_ufkt->str_startx = tmp_ufkt.str_startx; + added_ufkt->str_starty = tmp_ufkt.str_starty; + added_ufkt->oldx = tmp_ufkt.oldx; + added_ufkt->starty = tmp_ufkt.starty; + added_ufkt->startx = tmp_ufkt.startx; + added_ufkt->integral_precision = tmp_ufkt.integral_precision; + added_ufkt->color = tmp_ufkt.color; + added_ufkt->f1_color = tmp_ufkt.f1_color; + added_ufkt->f2_color = tmp_ufkt.f2_color; + added_ufkt->integral_color = tmp_ufkt.integral_color; + added_ufkt->parameters = tmp_ufkt.parameters; + added_ufkt->use_slider = tmp_ufkt.use_slider; + added_ufkt->usecustomxmin = tmp_ufkt.usecustomxmin; + added_ufkt->usecustomxmax = tmp_ufkt.usecustomxmax; + m_updatedfunction = added_ufkt; + + + // call inherited method + QEditParametric::accept(); //update the function name in FktDlg +} + +QString KEditParametric::xFunction() +{ + return "x" + kLineEditName->text() + "(t)=" + kLineEditXFunction->text(); +} + +void KEditParametric::splitEquation( const QString equation, QString &name, QString &expression ) +{ + int start = 0; + if( equation[ 0 ] == 'x' || equation[ 0 ] == 'y' ) start++; + int length = equation.find( '(' ) - start; + name = equation.mid( start, length ); + + expression = equation.section( '=', 1, 1 ); +} + +QString KEditParametric::yFunction() +{ + return "y" + kLineEditName->text() + "(t)=" + kLineEditYFunction->text(); +} + +Ufkt * KEditParametric::functionItem() +{ + return m_updatedfunction; +} + +void KEditParametric::slotHelp() +{ + kapp->invokeHelp( "", "kmplot" ); +} +void KEditParametric::customMinRange_toggled(bool status) +{ + if (status) + min->setEnabled(true); + else + min->setEnabled(false); +} + +void KEditParametric::customMaxRange_toggled(bool status) +{ + if (status) + max->setEnabled(true); + else + max->setEnabled(false); +} diff --git a/kmplot/kmplot/keditparametric.h b/kmplot/kmplot/keditparametric.h new file mode 100644 index 00000000..0ce5b2d4 --- /dev/null +++ b/kmplot/kmplot/keditparametric.h @@ -0,0 +1,81 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KEDITPARAMETRIC_H +#define KEDITPARAMETRIC_H + +#include "qeditparametric.h" +#include "xparser.h" + +class View; +class XParser; + +/** @short Dialog window editing a parametric plot and its properties. */ +class KEditParametric : public QEditParametric +{ + Q_OBJECT + public: + /// @param parser points to the parser instance. + /// @param parent points to the parent widget. + /// @param name of this instance. + KEditParametric( XParser* parser, QWidget* parent = NULL, const char* name = NULL ); + /// Nothing special to do. + virtual ~KEditParametric() {} + + /// Fill the dialog's widgets with the properties of the parser function number id. + void initDialog( int x_id = -1, int y_id = -1 ); + /// Returns a pointer to the added/inserted y-function, or 0 if the user havn't pressed OK yet + Ufkt *functionItem(); + + private: + /// Clear alls widgets values + void clearWidgets(); + /// Fill the dialog's widgets with values from the parser + void setWidgets(); + /// Returns the well formed function equation + QString xFunction(); + /// Returns the well formed function equation + QString yFunction(); + /// extract function \a name and \a expression from a given \a equation + void splitEquation( const QString equation, QString &name, QString &expression ); + /// Pointer to the parser instance. + XParser* m_parser; + //@{ + /// Current function indices. + int m_x_id, m_y_id; + //@} + + protected slots: + /// Overwrites the dialog's accept() method to make sure, that the user's input is valid. + virtual void accept(); + /// Invokes the HelpCenter. + void slotHelp(); + void customMaxRange_toggled(bool); + void customMinRange_toggled(bool); + + Ufkt *m_updatedfunction; +}; + +#endif diff --git a/kmplot/kmplot/keditpolar.cpp b/kmplot/kmplot/keditpolar.cpp new file mode 100644 index 00000000..7499be1a --- /dev/null +++ b/kmplot/kmplot/keditpolar.cpp @@ -0,0 +1,250 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ +// Qt includes +#include <qcheckbox.h> + +// KDE includes +#include <kapplication.h> +#include <kcolorbutton.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <knuminput.h> + + +#include <kdebug.h> + +// local includes +#include "keditpolar.h" +#include "keditpolar.moc" +#include "xparser.h" +#include "View.h" + +KEditPolar::KEditPolar( XParser* parser, QWidget* parent, const char* name ) : + QEditPolar( parent, name ),m_parser(parser) +{ + connect( customMinRange, SIGNAL ( toggled(bool) ), this, SLOT( customMinRange_toggled(bool) ) ); + connect( customMaxRange, SIGNAL ( toggled(bool) ), this, SLOT( customMaxRange_toggled(bool) ) ); + m_updatedfunction = 0; +} + +void KEditPolar::initDialog( int id ) +{ + m_id = id; + if( m_id == -1 ) clearWidgets(); + else setWidgets(); +} + +void KEditPolar::clearWidgets() +{ + kLineEditYFunction->clear(); + checkBoxHide->setChecked( false ); + customMinRange->setChecked( false ); + customMaxRange->setChecked(false); + min->clear(); + max->clear(); + kIntNumInputLineWidth->setValue( m_parser->linewidth0 ); + kColorButtonColor->setColor( m_parser->defaultColor(m_parser->getNextIndex() ) ); +} + +void KEditPolar::setWidgets() +{ + Ufkt *ufkt = &m_parser->ufkt[ m_parser->ixValue(m_id) ]; + QString function = ufkt->fstr; + function = function.right( function.length()-1 ); + kLineEditYFunction->setText( function ); + checkBoxHide->setChecked( !ufkt->f_mode); + if (ufkt->usecustomxmin) + { + customMinRange->setChecked(true); + min->setText( ufkt->str_dmin ); + } + else + customMinRange->setChecked(false); + + if (ufkt->usecustomxmin) + { + customMaxRange->setChecked(true); + max->setText( ufkt->str_dmax ); + } + else + customMaxRange->setChecked(false); + + kIntNumInputLineWidth->setValue( ufkt->linewidth ); + kColorButtonColor->setColor( ufkt->color ); +} + +void KEditPolar::accept() +{ + QString f_str = /*"r" + */kLineEditYFunction->text(); + + if ( m_id!=-1 ) + m_parser->fixFunctionName(f_str, XParser::Polar, m_id); + else + m_parser->fixFunctionName(f_str, XParser::Polar); + Ufkt tmp_ufkt; //all settings are saved here until we know that no errors have appeared + + tmp_ufkt.f_mode = !checkBoxHide->isChecked(); + + if( customMinRange->isChecked() ) + { + tmp_ufkt.usecustomxmin = true; + tmp_ufkt.str_dmin = min->text(); + tmp_ufkt.dmin = m_parser->eval( min->text() ); + if ( m_parser->parserError() ) + { + min->setFocus(); + min->selectAll(); + return; + } + } + else + tmp_ufkt.usecustomxmin = false; + if( customMaxRange->isChecked() ) + { + tmp_ufkt.usecustomxmax = true; + tmp_ufkt.str_dmax = max->text(); + tmp_ufkt.dmax = m_parser->eval( max->text() ); + if ( m_parser->parserError()) + { + max->setFocus(); + max->selectAll(); + return; + } + if ( tmp_ufkt.usecustomxmin && tmp_ufkt.dmin >= tmp_ufkt.dmax) + { + KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value")); + min->setFocus(); + min->selectAll(); + return; + } + } + else + tmp_ufkt.usecustomxmax = false; + + tmp_ufkt.f1_mode = 0; + tmp_ufkt.f2_mode = 0; + tmp_ufkt.integral_mode = 0; + tmp_ufkt.linewidth = kIntNumInputLineWidth->value(); + tmp_ufkt.color = kColorButtonColor->color().rgb(); + tmp_ufkt.use_slider = -1; + + Ufkt *added_ufkt; + if( m_id != -1 ) //when editing a function: + { + int const ix = m_parser->ixValue(m_id); + if ( ix == -1) //The function could have been deleted + { + KMessageBox::error(this,i18n("Function could not be found")); + return; + } + added_ufkt = &m_parser->ufkt[ix]; + QString const old_fstr = added_ufkt->fstr; + added_ufkt->fstr = f_str; + m_parser->reparse(added_ufkt); //reparse the funcion + if ( m_parser->parserError() != 0) + { + added_ufkt->fstr = old_fstr; + m_parser->reparse(added_ufkt); + raise(); + kLineEditYFunction->setFocus(); + kLineEditYFunction->selectAll(); + return; + } + } + else + { + int const id = m_parser->addfkt(f_str ); + kdDebug() << "id: " << id << endl; + if( id == -1 ) + { + m_parser->parserError(); + raise(); + kLineEditYFunction->setFocus(); + kLineEditYFunction->selectAll(); + return; + } + added_ufkt = &m_parser->ufkt.last(); + } + //save all settings in the function now when we know no errors have appeared + added_ufkt->f_mode = tmp_ufkt.f_mode; + added_ufkt->f1_mode = tmp_ufkt.f1_mode; + added_ufkt->f2_mode = tmp_ufkt.f2_mode; + added_ufkt->integral_mode = tmp_ufkt.integral_mode; + added_ufkt->integral_use_precision = tmp_ufkt.integral_use_precision; + added_ufkt->linewidth = tmp_ufkt.linewidth; + added_ufkt->f1_linewidth = tmp_ufkt.f1_linewidth; + added_ufkt->f2_linewidth = tmp_ufkt.f2_linewidth; + added_ufkt->integral_linewidth = tmp_ufkt.integral_linewidth; + added_ufkt->str_dmin = tmp_ufkt.str_dmin; + added_ufkt->str_dmax = tmp_ufkt.str_dmax; + added_ufkt->dmin = tmp_ufkt.dmin; + added_ufkt->dmax = tmp_ufkt.dmax; + added_ufkt->str_startx = tmp_ufkt.str_startx; + added_ufkt->str_starty = tmp_ufkt.str_starty; + added_ufkt->oldx = tmp_ufkt.oldx; + added_ufkt->starty = tmp_ufkt.starty; + added_ufkt->startx = tmp_ufkt.startx; + added_ufkt->integral_precision = tmp_ufkt.integral_precision; + added_ufkt->color = tmp_ufkt.color; + added_ufkt->f1_color = tmp_ufkt.f1_color; + added_ufkt->f2_color = tmp_ufkt.f2_color; + added_ufkt->integral_color = tmp_ufkt.integral_color; + added_ufkt->parameters = tmp_ufkt.parameters; + added_ufkt->use_slider = tmp_ufkt.use_slider; + added_ufkt->usecustomxmin = tmp_ufkt.usecustomxmin; + added_ufkt->usecustomxmax = tmp_ufkt.usecustomxmax; + + m_updatedfunction = added_ufkt; + + // call inherited method + QEditPolar::accept(); +} + +Ufkt *KEditPolar::functionItem() +{ + return m_updatedfunction; +} + +void KEditPolar::slotHelp() +{ + kapp->invokeHelp( "", "kmplot" ); +} + +void KEditPolar::customMinRange_toggled(bool status) +{ + if (status) + min->setEnabled(true); + else + min->setEnabled(false); +} + +void KEditPolar::customMaxRange_toggled(bool status) +{ + if (status) + max->setEnabled(true); + else + max->setEnabled(false); +} diff --git a/kmplot/kmplot/keditpolar.h b/kmplot/kmplot/keditpolar.h new file mode 100644 index 00000000..4189450a --- /dev/null +++ b/kmplot/kmplot/keditpolar.h @@ -0,0 +1,73 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KEDITPOLAR_H +#define KEDITPOLAR_H + +#include "qeditpolar.h" +#include "xparser.h" + +class View; +class XParser; + +/** @short Dialog window editing a polar plot and its properties. */ +class KEditPolar : public QEditPolar +{ + Q_OBJECT + public: + /// @param parser points to the parser instance. + /// @param parent points to the parent widget. + /// @param name of this instance. + KEditPolar( XParser* parser, QWidget* parent = NULL, const char* name = NULL ); + /// Nothing special to do. + virtual ~KEditPolar() {} + + ///Fill the dialog widgets with the properties of the parser function number id. + void initDialog( int id = -1 ); + /// Returns a pointer to the added/updated function + Ufkt * functionItem(); + + private: + /// Clear alls widgets values. + void clearWidgets(); + /// Fill the dialog's widgets with values from the parser. + void setWidgets(); + /// Pointer to the parser instance. + XParser* m_parser; + /// Current function id. + int m_id; + + protected slots: + /// Overwrites the dialog's accept() method to make sure, that the user's input is valid. + virtual void accept(); + /// Invokes the helpCenter. + void slotHelp(); + void customMinRange_toggled(bool); + void customMaxRange_toggled(bool); + + Ufkt *m_updatedfunction; +}; + +#endif diff --git a/kmplot/kmplot/kminmax.cpp b/kmplot/kmplot/kminmax.cpp new file mode 100644 index 00000000..bf4e69a8 --- /dev/null +++ b/kmplot/kmplot/kminmax.cpp @@ -0,0 +1,435 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include <kinputdialog.h> +#include <klineedit.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpushbutton.h> +#include <qlabel.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + + +#include "kminmax.h" +#include "xparser.h" + +KMinMax::KMinMax(View *v, QWidget *parent, const char *name) + : QMinMax(parent, name), m_view(v) +{ + m_mode=-1; + connect( cmdClose, SIGNAL( clicked() ), this, SLOT( close() )); + connect( cmdFind, SIGNAL( clicked() ), this, SLOT( cmdFind_clicked() )); + connect( cmdParameter, SIGNAL( clicked() ), this, SLOT( cmdParameter_clicked() )); + connect( list, SIGNAL( highlighted(QListBoxItem*) ), this, SLOT( list_highlighted(QListBoxItem*) )); + connect( list, SIGNAL( doubleClicked( QListBoxItem * ) ), this, SLOT( list_doubleClicked(QListBoxItem *) )); + parameter=""; +} + + +void KMinMax::init(char m) +{ + if ( m_mode==m) + { + if ( m_mode == 2) //get y-value + max->setText(""); + updateFunctions(); + return; + } + + m_mode = m; + if ( m_mode < 2) //find minimum point + { + max->setReadOnly(false); + QString range; + range.setNum(View::xmin); + min->setText( range); + range.setNum(View::xmax); + max->setText(range); + lblMin->setText(i18n("Search between the x-value:")); + lblMax->setText(i18n("and:")); + cmdFind->setText(i18n("&Find")); + QToolTip::add(min,i18n("Lower boundary of the plot range")); + QWhatsThis::add(min,i18n("Enter the lower boundary of the plot range. Expressions like 2*pi are allowed, too.")); + QToolTip::add(max,i18n("Upper boundary of the plot range")); + QWhatsThis::add(max,i18n("Enter the upper boundary of the plot range. Expressions like 2*pi are allowed, too.")); + + if ( m_mode == 1) //find maximum point + { + setCaption(i18n("Find Maximum Point")); + QToolTip::add( cmdFind, i18n( "Search for the maximum point in the range you specified" ) ); + QWhatsThis::add(cmdFind,i18n("Search for the highest y-value in the x-range you specified and show the result in a message box.")); + } + else + { + setCaption(i18n("Find Minimum Point")); + QToolTip::add( cmdFind, i18n( "Search for the minimum point in the range you specified" ) ); + QWhatsThis::add(cmdFind,i18n("Search for the lowest y-value in the x-range you specified and show the result in a message box.")); + } + } + else if ( m_mode == 2) //get y-value + { + setCaption(i18n("Get y-Value")); + lblMin->setText(i18n("X:")); + lblMax->setText(i18n("Y:")); + max->setReadOnly(true); + min->setText(""); + max->setText(""); + QToolTip::add(min,i18n("Lower boundary of the plot range")); + QWhatsThis::add(min,i18n("Enter the lower boundary of the plot range. Expressions like 2*pi are allowed, too.")); + QToolTip::add(max,i18n("No returned y-value yet")); + QWhatsThis::add(max,i18n("Here you will see the y-value which you got from the x-value in the textbox above. To calculate the y-value, press the Calculate button.")); + + cmdFind->setText(i18n("&Calculate")); + QToolTip::add( cmdFind, i18n( "Get the y-value from the x-value you typed" ) ); + QWhatsThis::add(cmdFind,i18n("Get the y-value from the x-value you typed and show it in the y-value box.")); + + } + else if ( m_mode == 3) //area under a graph + { + max->setReadOnly(false); + QString range; + range.setNum(View::xmin); + min->setText( range); + range.setNum(View::xmax); + max->setText(range); + QToolTip::add(min,i18n("Lower boundary of the plot range")); + QWhatsThis::add(min,i18n("Enter the lower boundary of the plot range. Expressions like 2*pi are allowed, too.")); + QToolTip::add(max,i18n("Upper boundary of the plot range")); + QWhatsThis::add(max,i18n("Enter the upper boundary of the plot range. Expressions like 2*pi are allowed, too.")); + + setCaption(i18n("Calculate Integral")); + lblMin->setText(i18n("Calculate the integral between the x-values:")); + lblMax->setText(i18n("and:")); + cmdFind->setText(i18n("&Calculate")); + QToolTip::add( cmdFind, i18n( "Calculate the integral between the x-values" ) ); + QWhatsThis::add(cmdFind,i18n("Calculate the numeric integral between the x-values and draw the result as an area.")); + + } + + min->setFocus(); + updateFunctions(); +} + +void KMinMax::updateFunctions() +{ + QString const selected_item(list->currentText() ); + list->clear(); + + for( QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it != m_view->parser()->ufkt.end(); ++it) + { + if( it->fname[0] != 'x' && it->fname[0] != 'y' && it->fname[0] != 'r' && !it->fname.isEmpty()) + { + if ( it->f_mode ) + list->insertItem(it->fstr); + + if ( it->f1_mode ) //1st derivative + { + QString function (it->fstr); + int i= function.find('('); + function.truncate(i); + function +="\'"; + list->insertItem(function ); + } + if ( it->f2_mode )//2nd derivative + { + QString function (it->fstr); + int i= function.find('('); + function.truncate(i); + function +="\'\'"; + list->insertItem(function ); + } + if ( it->integral_mode )//integral + { + QString function (it->fstr); + int i= function.find('('); + function.truncate(i); + function = function.upper(); + list->insertItem(function ); + } + } + } + list->sort(); + if (list->count()==0) //empty list + cmdFind->setEnabled(false); + else + cmdFind->setEnabled(true); + selectItem(); + QListBoxItem *found_item = list->findItem(selected_item,Qt::ExactMatch); + if ( found_item && m_view->csmode < 0) + list->setSelected(found_item,true); +} + +void KMinMax::selectItem() +{ + cmdParameter->hide(); + if ( m_view->csmode < 0) + return; + //kdDebug() << "cstype: " << (int)m_view->cstype << endl; + Ufkt *ufkt = &m_view->parser()->ufkt[m_view->parser()->ixValue(m_view->csmode)]; + QString function = ufkt->fstr; + if ( m_view->cstype == 2) + { + int i= function.find('('); + function.truncate(i); + function +="\'\'"; + } + else if ( m_view->cstype == 1) + { + int i= function.find('('); + function.truncate(i); + function +="\'"; + } + //kdDebug() << "function: " << function << endl; + QListBoxItem *item = list->findItem(function,Qt::ExactMatch); + list->setSelected(item,true); + + if ( !ufkt->parameters.isEmpty() ) + parameter = ufkt->parameters[m_view->csparam].expression; +} + +KMinMax::~KMinMax() +{ +} + +void KMinMax::cmdFind_clicked() +{ + if ( list->currentItem() == -1) + { + KMessageBox::error(this, i18n("Please choose a function")); + return; + } + double dmin, dmax; + dmin = m_view->parser()->eval(min->text() ); + if ( m_view->parser()->parserError()!=0 ) + { + min->setFocus(); + min->selectAll(); + return; + } + if ( m_mode != 2) + { + dmax = m_view->parser()->eval(max->text() ); + if ( m_view->parser()->parserError()!=0 ) + { + max->setFocus(); + max->selectAll(); + return; + } + if ( dmin >= dmax) + { + KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value")); + min->setFocus(); + min->selectAll(); + return; + } + + if ( dmin<View::xmin || dmax>View::xmax ) + { + KMessageBox::error(this,i18n("Please insert a minimum and maximum range between %1 and %2").arg(View::xmin).arg(View::xmax) ); + min->setFocus(); + min->selectAll(); + return; + } + } + + + QString function( list->currentText() ); + char p_mode = 0; + if ( function.contains('\'') == 1) + { + p_mode = 1; + int pos = function.find('\''); + function.remove(pos,1); + } + else if ( function.contains('\'') == 2) + { + p_mode = 2; + int pos = function.find('\''); + function.remove(pos,2); + } + else if ( function.at(0).category() == QChar::Letter_Uppercase) + { + p_mode = 3; + function.at(0) = function.at(0).lower(); + } + + QString fname, fstr; + Ufkt *ufkt = 0; + QString sec_function = function.section('(',0,0); + + for( QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it != m_view->parser()->ufkt.end(); ++it) + { + if ( it->fstr.section('(',0,0) == sec_function) + { + ufkt = it; + break; + } + } + if ( !ufkt) + { + KMessageBox::error(this,i18n("Function could not be found")); + return; + } + + if ( ufkt->parameters.isEmpty() ) + parameter = "0"; + else if ( parameter.isEmpty()) + { + KMessageBox::error(this,i18n("You must choose a parameter for that function")); + list_highlighted(list->selectedItem() ); + return; + } + + + if ( m_mode == 0) + { + m_view->findMinMaxValue(ufkt,p_mode,true,dmin,dmax,parameter); + if ( !m_view->isCalculationStopped() ) + KMessageBox::information(this,i18n("Minimum value:\nx: %1\ny: %2").arg(dmin).arg(dmax) ); + } + else if ( m_mode == 1) + { + m_view->findMinMaxValue(ufkt,p_mode,false,dmin,dmax,parameter); + if ( !m_view->isCalculationStopped() ) + KMessageBox::information(this,i18n("Maximum value:\nx: %1\ny: %2").arg(dmin).arg(dmax)); + } + else if ( m_mode == 2) + { + m_view->getYValue(ufkt,p_mode,dmin,dmax,parameter); + if ( !m_view->isCalculationStopped() ) + { + QString tmp; + tmp.setNum(dmax); + max->setText(tmp); + } + QToolTip::add(max,i18n("The returned y-value")); + QWhatsThis::add(max,i18n("Here you see the result of the calculation: the returned y-value you got from the x-value in the textbox above")); + } + else if ( m_mode == 3) + { + double dmin_tmp = dmin; + m_view->areaUnderGraph(ufkt,p_mode,dmin,dmax,parameter, 0); + if ( !m_view->isCalculationStopped() ) + { + m_view->setFocus(); + m_view->update(); + KMessageBox::information(this,i18n("The integral in the interval [%1, %2] is:\n%3").arg(dmin_tmp).arg(dmax).arg(dmin)); + } + } + + if ( m_view->isCalculationStopped() ) + KMessageBox::error(this,i18n("The operation was cancelled by the user.")); +} +void KMinMax::list_highlighted(QListBoxItem* item) +{ + if ( !item) + { + cmdParameter->hide(); + return; + } + QString function( list->currentText() ); + char p_mode = 0; + if ( function.contains('\'') == 1) + { + p_mode = 1; + int pos = function.find('\''); + function.remove(pos,1); + } + else if ( function.contains('\'') == 2) + { + p_mode = 2; + int pos = function.find('\''); + function.remove(pos,2); + } + else if ( function.at(0).category() == QChar::Letter_Uppercase) + { + p_mode = 3; + function.at(0) = function.at(0).lower(); + } + QString const sec_function = function.section('(',0,0); + for(QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin(); it!=m_view->parser()->ufkt.end(); ++it) + { + if ( it->fstr.section('(',0,0) == sec_function) + { + if ( it->parameters.count() == 0) + cmdParameter->hide(); + else + { + cmdParameter->show(); + if (parameter.isEmpty() ) + parameter = it->parameters.first().expression; + } + break; + } + } +} +void KMinMax::cmdParameter_clicked() +{ + QString function( list->currentText() ); + char p_mode = 0; + if ( function.contains('\'') == 1) + { + p_mode = 1; + int pos = function.find('\''); + function.remove(pos,1); + } + else if ( function.contains('\'') == 2) + { + p_mode = 2; + int pos = function.find('\''); + function.remove(pos,2); + } + else if ( function.at(0).category() == QChar::Letter_Uppercase) + { + p_mode = 3; + function.at(0) = function.at(0).lower(); + } + + QString const sec_function = function.section('(',0,0); + for(QValueVector<Ufkt>::iterator it = m_view->parser()->ufkt.begin() ; it!=m_view->parser()->ufkt.end(); ++it) + { + if ( it->fstr.section('(',0,0) == sec_function) + { + QStringList str_parameters; + for ( QValueList<ParameterValueItem>::Iterator k = it->parameters.begin(); k != it->parameters.end(); ++k ) + str_parameters.append( (*k).expression); + bool ok; + QStringList result = KInputDialog::getItemList( i18n("Choose Parameter"), i18n("Choose a parameter to use:"), str_parameters, QStringList(parameter),false,&ok,this ); + if ( ok) + parameter = result.first(); + break; + } + } +} + +void KMinMax::list_doubleClicked(QListBoxItem *) +{ + if ( list->currentItem() == -1) + return; + else if( cmdParameter->isShown() ) + cmdParameter_clicked(); +} +#include "kminmax.moc" diff --git a/kmplot/kmplot/kminmax.h b/kmplot/kmplot/kminmax.h new file mode 100644 index 00000000..3b818758 --- /dev/null +++ b/kmplot/kmplot/kminmax.h @@ -0,0 +1,68 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KMINMAX_H +#define KMINMAX_H + +#include "qminmax.h" +#include "View.h" + +/** +@author Fredrik Edemar +*/ +/// KMinMax handles all the dialogs for the items in the tool-menu. +class KMinMax : public QMinMax +{ +Q_OBJECT +public: + KMinMax(View *, QWidget *parent = 0, const char *name = 0); + /// called every time the dialog is opened + void init(char); + /// update the list with functions + void updateFunctions(); + /// select the right function when using the popup menu to show the dialog + void selectItem(); + + ~KMinMax(); + +public slots: + /// the user has pressen the find/caluclate/draw button + void cmdFind_clicked(); + /// the selecting a function that uses parameter function from a list the user can choose which paramater value he/she wants to use + void cmdParameter_clicked(); + /// the button for changing the selected parameter value + void list_highlighted(QListBoxItem*); + /// call cmdParameter_clicked() if parameter values is enabled for that function + void list_doubleClicked(QListBoxItem *); + +private: + View *m_view; + char m_mode; //< 0 = minimum, 1 = maximum, 2 = y-point, 3=drawing area + QString parameter; + + +}; + +#endif diff --git a/kmplot/kmplot/kmplot.cpp b/kmplot/kmplot/kmplot.cpp new file mode 100644 index 00000000..3b0e8b3c --- /dev/null +++ b/kmplot/kmplot/kmplot.cpp @@ -0,0 +1,318 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include "kmplot.h" + +#include <kaction.h> +#include <kconfig.h> +#include <kedittoolbar.h> +#include <kkeydialog.h> +#include <kfiledialog.h> +#include <klibloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kstatusbar.h> +#include <kstdaction.h> +#include <kurl.h> + +#include "MainDlg.h" +#include "kmplotprogress.h" + +KmPlot::KmPlot( KCmdLineArgs* args) + : DCOPObject( "KmPlotShell" ), KParts::MainWindow( 0L, "KmPlot" ) +{ + // set the shell's ui resource file + setXMLFile("kmplot_shell.rc"); + // then, setup our actions + setupActions(); + + // setup the status bar + setupStatusBar(); + + // this routine will find and load our Part. it finds the Part by + // name which is a bad idea usually.. but it's alright in this + // case since our Part is made for this Shell + KLibFactory *factory = KLibLoader::self()->factory("libkmplotpart"); + if (factory) + { + // now that the Part is loaded, we cast it to a Part to get + // our hands on it + m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this, + "kmplot_part", "KParts::ReadOnlyPart" )); + if (m_part) + { + // tell the KParts::MainWindow that this is indeed the main widget + setCentralWidget(m_part->widget()); + //m_part->widget()->setFocus(); + // and integrate the part's GUI with the shell's + createGUI(m_part); + } + } + else + { + // if we couldn't find our Part, we exit since the Shell by + // itself can't do anything useful + KMessageBox::error(this, i18n("Could not find KmPlot's part.")); + kapp->quit(); + // we return here, cause kapp->quit() only means "exit the + // next time we enter the event loop... + return; + } + + if (!initialGeometrySet()) + resize( QSize(450, 520).expandedTo(minimumSizeHint())); + + // apply the saved mainwindow settings, if any, and ask the mainwindow + // to automatically save settings if changed: window size, toolbar + // position, icon size, etc. + setAutoSaveSettings(); + if (args) + { + bool exit = false; + for (int i=0; i < args->count(); i++ ) + { + if (i==0) + { + if (!load(args->url(0) ) ) + exit = true; + } + else + openFileInNewWindow( args->url(i) ); + } + args->clear(); + if (exit) + deleteLater(); // couln't open the file, and therefore exit + } +} + +KmPlot::~KmPlot() +{} + +void KmPlot::slotUpdateFullScreen( bool checked) +{ + if (checked) + { + showFullScreen(); + m_fullScreen->plug( toolBar( "mainToolBar" ) ); + } + else + { + showNormal(); + m_fullScreen->unplug( toolBar( "mainToolBar" ) ); + } +} + +bool KmPlot::load(const KURL& url) +{ + m_part->openURL( url ); + if (m_part->url().isEmpty()) + return false; + setCaption(url.prettyURL(0, KURL::StripFileProtocol)); + return true; +} + +void KmPlot::setupActions() +{ + KStdAction::openNew(this, SLOT(fileNew()), actionCollection()); + KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + KStdAction::quit(kapp, SLOT(quit()), actionCollection()); + + createStandardStatusBarAction(); + setStandardToolBarMenuEnabled(true); + + KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection()); + KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); + + m_fullScreen = KStdAction::fullScreen( NULL, NULL, actionCollection(), this, "fullscreen"); + connect( m_fullScreen, SIGNAL( toggled( bool )), this, SLOT( slotUpdateFullScreen( bool ))); +} + +void KmPlot::saveProperties(KConfig* /*config*/) +{ + // the 'config' object points to the session managed + // config file. anything you write here will be available + // later when this app is restored +} + +void KmPlot::readProperties(KConfig* /*config*/) +{ + // the 'config' object points to the session managed + // config file. this function is automatically called whenever + // the app is being restored. read in here whatever you wrote + // in 'saveProperties' +} + +void KmPlot::fileNew() +{ + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here.. + if ( !m_part->url().isEmpty() || isModified() ) + //KApplication::startServiceByDesktopName("kmplot"); + KApplication::kdeinitExec("kmplot"); +} + +bool KmPlot::stopProgressBar() +{ + if (m_progressbar && m_progressbar->isShown()) + { + m_progressbar->hide(); + return true; + } + return false; +} + +void KmPlot::startProgressBar(int steps) +{ + if (m_progressbar) + { + m_progressbar->progress->setTotalSteps(steps); + m_progressbar->show(); + } +} + +void KmPlot::increaseProgressBar() +{ + if (m_progressbar) + m_progressbar->increase(); +} + +void KmPlot::optionsConfigureKeys() +{ + KKeyDialog::configure(actionCollection(), "kmplot_shell.rc"); +} + +void KmPlot::optionsConfigureToolbars() +{ + saveMainWindowSettings(KGlobal::config() ); + // use the standard toolbar editor + KEditToolbar dlg(factory()); + connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(applyNewToolbarConfig())); + dlg.exec(); +} + +void KmPlot::applyNewToolbarConfig() +{ + applyMainWindowSettings(KGlobal::config()); +} + +void KmPlot::fileOpen() +{ + // this slot is called whenever the File->Open menu is selected, + // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar + // button is clicked + KURL const url = KFileDialog::getOpenURL( QDir::currentDirPath(), + i18n( "*.fkt|KmPlot Files (*.fkt)\n*.*|All Files" ), this, i18n( "Open" ) ); + + if ( !url.isEmpty()) + { + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here.. + if ( m_part->url().isEmpty() && !isModified() ) + load( url ); // we open the file in this window... + else + openFileInNewWindow(url); // we open the file in a new window... + } +} + +void KmPlot::fileOpen(const KURL &url) +{ + if ( !url.isEmpty()) + { + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here.. + if ( m_part->url().isEmpty() && !isModified() ) + load( KStandardDirs::realFilePath(url.url())); // we open the file in this window... + else + openFileInNewWindow(url); // we open the file in a new window... + } +} + + +void KmPlot::openFileInNewWindow(const KURL url) +{ + KApplication::startServiceByDesktopName("kmplot",url.url()); +} + +bool KmPlot::checkModified() +{ + QCString replyType; + QByteArray replyData; + kapp->dcopClient()->call(kapp->dcopClient()->appId(), "MainDlg","checkModified()", QByteArray(), replyType, replyData, false); + bool result; + QDataStream stream(replyData, IO_ReadOnly); + stream >> result; + return result; +} + +bool KmPlot::isModified() +{ + QCString replyType; + QByteArray replyData; + kapp->dcopClient()->call(kapp->dcopClient()->appId(), "MainDlg","isModified()", QByteArray(), replyType, replyData, false); + bool result; + QDataStream stream(replyData, IO_ReadOnly); + stream >> result; + return result; +} + +bool KmPlot::queryClose() +{ + return checkModified(); +} + +void KmPlot::setStatusBarText(const QString &text, int id) +{ + statusBar()->changeItem(text,id); +} + + +void KmPlot::setupStatusBar() +{ + statusBar()->insertFixedItem( "1234567890", 1 ); + statusBar()->insertFixedItem( "1234567890", 2 ); + statusBar()->insertItem( "", 3, 3 ); + statusBar()->insertItem( "", 4 ); + statusBar()->changeItem( "", 1 ); + statusBar()->changeItem( "", 2 ); + statusBar()->setItemAlignment( 3, AlignLeft ); + + m_progressbar = new KmPlotProgress( statusBar() ); + m_progressbar->setMaximumHeight( statusBar()->height()-10 ); + connect( m_progressbar->button, SIGNAL (clicked() ), this, SLOT( progressbar_clicked() ) ); + statusBar()->addWidget(m_progressbar); +} + +void KmPlot::progressbar_clicked() +{ + kapp->dcopClient()->send(kapp->dcopClient()->appId(), "View","stopDrawing()", QByteArray()); +} + +#include "kmplot.moc" diff --git a/kmplot/kmplot/kmplot.desktop b/kmplot/kmplot/kmplot.desktop new file mode 100644 index 00000000..7e6d1237 --- /dev/null +++ b/kmplot/kmplot/kmplot.desktop @@ -0,0 +1,134 @@ +# KDE Config File +[Desktop Entry] +Type=Application +Exec=kmplot +Icon=kmplot +DocPath=kmplot/index.html +Comment=Function Plotter +Comment[af]=Funksieplotter +Comment[ar]=مخطط وظيفة +Comment[be]=Маляванне графікаў функцый +Comment[bg]=Чертане на функции +Comment[bn]=ফাংশন প্লটার +Comment[br]=Tresell fonksion +Comment[bs]=Crtač funkcija +Comment[ca]=Traçador de funcions +Comment[cs]=Zobrazení funkce +Comment[csb]=Programa céchùjąca dijagramë fùnkcëji +Comment[cy]=Plotydd Ffwythiannau +Comment[da]=Funktionsprogram +Comment[de]=Funktionsplotter +Comment[el]=Γραφική αναπαράσταση συναρτήσεων +Comment[eo]=Funkcia desegnilo +Comment[es]=Trazador de funciones +Comment[et]=Funktsioonide graafiku joonistaja +Comment[eu]=Funtzio-marrazkigilea +Comment[fa]=رسام تابع +Comment[fi]=Kuvaajapiirturi +Comment[fo]=Funkateknari +Comment[fr]=Traceur de courbes +Comment[ga]=Breacaire Feidhmeanna +Comment[gl]=Representación Gráfica de Funcións +Comment[he]=תווין פונקציות +Comment[hi]=फंक्शन प्लॉट करने वाला +Comment[hr]=Crtač funkcija +Comment[hu]=Függvényábrázoló +Comment[is]=Teiknar gröf falla +Comment[it]=Grafici di funzioni +Comment[ja]=関数プロッタ +Comment[ka]=ფუნქციების გრაფიკები +Comment[km]=កម្មវិធីគ្រោងអនុគមន៍ +Comment[lt]=funkcijinis braižytuvas +Comment[lv]=Funkciju Zīmētājs +Comment[mk]=Цртач на функции +Comment[mn]=Функцийн плоттер +Comment[ms]=Plot Fungsi +Comment[nb]=Funksjonsplotter +Comment[nds]=Bagenschriever för Funkschonen +Comment[ne]=प्रकार्य आलेखक +Comment[nl]=functieplotter +Comment[nn]=Funksjonsteiknar +Comment[nso]=Mmei wa Pereko +Comment[pl]=Program rysujący wykresy funkcji +Comment[pt]=Desenho de funções +Comment[pt_BR]=Desenho de funções +Comment[ru]=Построение графиков функций +Comment[se]=Funkšuvdnasárgojeaddji +Comment[sk]=Kreslenie funkcií +Comment[sl]=Risanje funkcij +Comment[sr]=Цртач функција +Comment[sr@Latn]=Crtač funkcija +Comment[sv]=Funktionsritare +Comment[ta]=இயக்க வரைவி +Comment[tg]=Плоттери Функсионалӣ +Comment[tr]=Fonksiyon Noktalayıcı +Comment[uk]=Побудова графіків функцій +Comment[ven]=Mushumo wa tshiiti tsha nyito +Comment[vi]=Vẽ đồ thị Hàm số +Comment[xh]=Umzobi Womsebenzi +Comment[zh_CN]=函数绘图程序 +Comment[zh_TW]=函數繪圖程式 +Comment[zu]=Umbheki Womsebenzi +Terminal=false +Name=KmPlot +Name[ar]=المخطط +Name[bn]=কে-এমপ্লট +Name[eo]=KmPloto +Name[hi]=के-एम-प्लॉट +Name[sv]=Kmplot +Name[ta]=கேஎம்பிளாட் +Name[ven]=Mutodo wa Km +Name[vi]=Đồ thị K +Categories=Qt;KDE;Education;Math; +MimeType=application/x-kmplot; +GenericName=Mathematical Function Plotter +GenericName[be]=Маляванне графікаў матэматычных функцый +GenericName[bg]=Интерактивна геометрия +GenericName[bn]=গাণিতিক ফাংশন প্লটার +GenericName[bs]=Crtač matematičkih funkcija +GenericName[ca]=Traçador de funcions matemàtiques +GenericName[cs]=Kreslení funkcí +GenericName[csb]=Programa céchùjącô matematiczne fùnkcëjë +GenericName[cy]=Plotydd Ffwythiannau Mathemategol +GenericName[da]=Matematisk funktionsplotter +GenericName[de]=Mathematischer Funktionsplotter +GenericName[el]=Γραφική αναπαράσταση συναρτήσεων +GenericName[eo]=Matematika funkcia desegnilo +GenericName[es]=Trazador de funciones matemáticas +GenericName[et]=Matemaatiliste funktsioonide graafiku joonistaja +GenericName[eu]=Funtzio matematikoen marrazkigilea +GenericName[fa]=رسام تابع ریاضی +GenericName[fi]=Matemaattisten funktioiden kuvaajapiirturi +GenericName[fr]=Traceur de fonctions mathématiques +GenericName[ga]=Breacaire Feidhmeanna Matamaiticiúla +GenericName[gl]=Representación Gráfica de Funcións +GenericName[he]=תוין פונקציות מתמטיות +GenericName[hr]=Crtač matematičkih funkcija +GenericName[hu]=Függvényábrázoló +GenericName[is]=Teiknar gröf falla +GenericName[it]=Grafici di funzioni matematiche +GenericName[ja]=数学関数プロッタ +GenericName[ka]=მათიმატიკური ფუნქციების გრაფიკები +GenericName[km]=កម្មវិធីគ្រោងអនុគមន៍គណិតវិទ្យា +GenericName[lt]=Matematinės funkcijos braižytuvas +GenericName[ms]=Pemplot Fungsi Matematik +GenericName[nb]=Matematisk Funksjonsplotter +GenericName[nds]=Mathemaatsch Bagenschriever +GenericName[ne]=गणित प्रकार्य आलेखक +GenericName[nl]=Wiskundige functieplotter +GenericName[nn]=Eit plotteprogram for matematiske funksjonar +GenericName[pl]=Program rysujący funkcje matematyczne +GenericName[pt]=Desenho de Funções Matemáticas +GenericName[pt_BR]=Desenho de funções matemáticas +GenericName[ru]=Графопостроитель функций +GenericName[sk]=Kreslenie matematických funkcií +GenericName[sl]=Risanje matematičnih funkcij +GenericName[sr]=Цртач математичких функција +GenericName[sr@Latn]=Crtač matematičkih funkcija +GenericName[sv]=Matematisk funktionsritare +GenericName[ta]=கணக்கியல் இயக்க வரைவி +GenericName[tr]=Matematiksel Fonksiyon Çizici +GenericName[uk]=Графобудівник математичних функцій +GenericName[vi]=Vẽ đồ thị Hàm số Toán học +GenericName[zh_CN]=数学函数绘图器 +GenericName[zh_TW]=函數繪圖程式 diff --git a/kmplot/kmplot/kmplot.h b/kmplot/kmplot/kmplot.h new file mode 100644 index 00000000..b2cf4242 --- /dev/null +++ b/kmplot/kmplot/kmplot.h @@ -0,0 +1,122 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KMPLOT_H_ +#define KMPLOT_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kparts/mainwindow.h> + +#include "kmplotIface.h" +#include "kmplotprogress.h" + +class KToggleAction; + +/** + * This is the application "Shell". It has a menubar, toolbar, and + * statusbar but relies on the "Part" to do all the real work. + * + * @short Application Shell + * @author Fredrik Edemar <f_edemar@linux.se> + */ +class KmPlot : public KParts::MainWindow, virtual public KmPlotIface +{ + Q_OBJECT +public: + /** + * Default Constructor + */ + KmPlot( KCmdLineArgs* args); + + /** + * Default Destructor + */ + virtual ~KmPlot(); + + /** + * Use this method to load whatever file/URL you have + */ + bool load(const KURL& url); + +protected: + /** + * This method is called when it is time for the app to save its + * properties for session management purposes. + */ + void saveProperties(KConfig *); + + /** + * This method is called when this app is restored. The KConfig + * object points to the session management config file that was saved + * with @ref saveProperties + */ + void readProperties(KConfig *); + + /// Quits KmPlot after checking if modifications shall be saved. + virtual bool queryClose(); + +private slots: + void fileNew(); + void fileOpen(); + void fileOpen(const KURL &url); + void optionsConfigureKeys(); + void optionsConfigureToolbars(); + void applyNewToolbarConfig(); + + /// Called when the user want to cancel the drawing + void progressbar_clicked(); + +public slots: + /// Called when fullscren is enabled/disabled + void slotUpdateFullScreen(bool); + void setStatusBarText(const QString &, int id); + +private: + void setupAccel(); + void setupActions(); + void setupStatusBar(); + bool checkModified(); + bool isModified(); + void openFileInNewWindow(const KURL url); + + /// Functions for the progressbar + bool stopProgressBar(); + void startProgressBar(int); + void increaseProgressBar(); + + +private: + KParts::ReadOnlyPart *m_part; + /// The fullscreen action to be plugged/unplegged to the toolbar + KToggleFullScreenAction* m_fullScreen; + KmPlotProgress *m_progressbar; +}; + +#endif // KMPLOT_H_ diff --git a/kmplot/kmplot/kmplot.kcfg b/kmplot/kmplot/kmplot.kcfg new file mode 100644 index 00000000..1963aac3 --- /dev/null +++ b/kmplot/kmplot/kmplot.kcfg @@ -0,0 +1,232 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + + <kcfgfile name="kmplotrc"/> + + <group name="Coordinate System"> + <entry name="AxesLineWidth" type="Int"> + <label>Axis-line width</label> + <whatsthis>Enter the width of the axis lines.</whatsthis> + <default>5</default> + </entry> + <entry name="ShowLabel" type="Bool"> + <label>Checked if labels are visible</label> + <whatsthis>Check this box if the labels at the tics should be shown.</whatsthis> + <default>true</default> + </entry> + <entry name="ShowAxes" type="Bool"> + <label>Checked if axes are visible</label> + <whatsthis>Check this box if axes should be shown.</whatsthis> + <default>true</default> + </entry> + <entry name="ShowArrows" type="Bool"> + <label>Checked if arrows are visible</label> + <whatsthis>Check this box if axes should have arrows.</whatsthis> + <default>true</default> + </entry> + <entry name="GridLineWidth" type="Int"> + <label>Grid Line Width</label> + <whatsthis>Enter the width of the grid lines.</whatsthis> + <default>1</default> + </entry> + <entry name="GridStyle" type="Int"> + <label>Grid Style</label> + <whatsthis>Choose a suitable grid style.</whatsthis> + <default>1</default> + </entry> + <entry name="ShowFrame" type="Bool"> + <label>Checked if a frame is visible</label> + <whatsthis>Check this box if a frame should be drawn around the plot area.</whatsthis> + <default>false</default> + </entry> + <entry name="ShowExtraFrame" type="Bool"> + <label>Checked if an extra frame is visible</label> + <whatsthis>Check this box if an extra frame should be drawn around the plot area.</whatsthis> + <default>true</default> + </entry> + <entry name="TicLength" type="Int"> + <label>Tic length</label> + <whatsthis>Enter the length of the tic lines</whatsthis> + <default>10</default> + </entry> + <entry name="TicWidth" type="Int"> + <label>Tic width</label> + <whatsthis>Enter the width of the tic lines.</whatsthis> + <default>1</default> + </entry> + <entry name="PlotLineWidth" type="Int"> + <label>Plot-line width</label> + <whatsthis>Enter the width of the plot line.</whatsthis> + <default>5</default> + </entry> + <entry name="XRange" type="Int"> + <label>Predefined x-axis range</label> + <whatsthis>Predefined plot area widths.</whatsthis> + <default>0</default> + </entry> + <entry name="YRange" type="Int"> + <label>Predefined y-axis range</label> + <whatsthis>Predefined plot area heights.</whatsthis> + <default>0</default> + </entry> + <entry name="XMin" type="String"> + <label>Left boundary</label> + <whatsthis>Enter the left boundary of the plotting area.</whatsthis> + <default>-2*pi</default> + </entry> + <entry name="XMax" type="String"> + <label>Right boundary</label> + <whatsthis>Enter the right boundary of the plotting area.</whatsthis> + <default>2*pi</default> + </entry> + <entry name="YMin" type="String"> + <label>Lower boundary</label> + <whatsthis>Enter the lower boundary of the plotting area.</whatsthis> + <default>-2*pi</default> + </entry> + <entry name="YMax" type="String"> + <label>Upper boundary</label> + <whatsthis>Enter the upper boundary of the plotting area.</whatsthis> + <default>2*pi</default> + </entry> + </group> + + <group name="Scaling"> + <entry name="XScaling" type="Int"> + <label>Width of a unit from tic to tic</label> + <whatsthis>Enter the width of a unit from tic to tic.</whatsthis> + <default>8</default> + </entry> + <entry name="YScaling" type="Int"> + <label>Height of a unit from tic to tic</label> + <whatsthis>Enter the height of a unit from tic to tic.</whatsthis> + <default>8</default> + </entry> + <entry name="XPrinting" type="Int"> + <label>Printed width of 1 unit</label> + <whatsthis>Enter the width of a unit in cm.</whatsthis> + <default>3</default> + </entry> + <entry name="YPrinting" type="Int"> + <label>Printed height of 1 unit</label> + <whatsthis>Enter the height of a unit in cm.</whatsthis> + <default>3</default> + </entry> + </group> + + <group name="Fonts"> + <entry name="AxesFont" type="String"> + <label>Font name of the axis labels</label> + <whatsthis>Choose a font name for the axis labels.</whatsthis> + <default code="true">KGlobalSettings::generalFont().family()</default> + </entry> + <entry name="AxesFontSize" type="Int"> + <label>Font size of the axis labels</label> + <whatsthis>Choose a font size for the axis labels.</whatsthis> + <default code="true">40</default> + </entry> + <entry name="HeaderTableFont" type="String"> + <label>Font name of the printed header table</label> + <whatsthis>Choose a font name for the table printed at the top of the page.</whatsthis> + <default code="true">KGlobalSettings::generalFont().family()</default> + </entry> + </group> + + <group name="Colors"> + <entry name="AxesColor" type="Color"> + <label>Axis-line color</label> + <whatsthis>Enter the color of the axis lines.</whatsthis> + </entry> + <entry name="GridColor" type="Color"> + <label>Grid Color</label> + <whatsthis>Choose a color for the grid lines.</whatsthis> + <default>#C0C0C0</default> + </entry> + <entry name="Color0" type="Color"> + <label>Color of function 1</label> + <whatsthis>Choose a color for function 1.</whatsthis> + <default>#FF0000</default> + </entry> + <entry name="Color1" type="Color"> + <label>Color of function 2</label> + <whatsthis>Choose a color for function 2.</whatsthis> + <default>#00FF00</default> + </entry> + <entry name="Color2" type="Color"> + <label>Color of function 3</label> + <whatsthis>Choose a color for function 3.</whatsthis> + <default>#0000FF</default> + </entry> + <entry name="Color3" type="Color"> + <label>Color of function 4</label> + <whatsthis>Choose a color for function 4.</whatsthis> + <default>#FF00FF</default> + </entry> + <entry name="Color4" type="Color"> + <label>Color of function 5</label> + <whatsthis>Choose a color for function 5.</whatsthis> + <default>#FFFF00</default> + </entry> + <entry name="Color5" type="Color"> + <label>Color of function 6</label> + <whatsthis>Choose a color for function 6.</whatsthis> + <default>#00FFFF</default> + </entry> + <entry name="Color6" type="Color"> + <label>Color of function 7</label> + <whatsthis>Choose a color for function 7.</whatsthis> + <default>#008000</default> + </entry> + <entry name="Color7" type="Color"> + <label>Color of function 8</label> + <whatsthis>Choose a color for function 8.</whatsthis> + <default>#000080</default> + </entry> + <entry name="Color8" type="Color"> + <label>Color of function 9</label> + <whatsthis>Choose a color for function 9.</whatsthis> + <default>#000000</default> + </entry> + <entry name="Color9" type="Color"> + <label>Color of function 10</label> + <whatsthis>Choose a color for function 10.</whatsthis> + <default>#000000</default> + </entry> + </group> + + <group name="General"> + <entry name="stepWidth" type="Double"> + <label>Step width in pixel</label> + <whatsthis>The greater the step width the faster but the less precise the plot is done.</whatsthis> + <default>1.0</default> + </entry> + <entry name="useRelativeStepWidth" type="Bool"> + <label>Use relative step width</label> + <whatsthis>If relative step width is set to true, the step width will be adapted to the size of the window.</whatsthis> + <default>true</default> + </entry> + <entry name="anglemode" type="Int"> + <label>Radians instead of degrees</label> + <whatsthis>Check the box if you want to use radians</whatsthis> + <default>0</default> + </entry> + <entry name="backgroundcolor" type="Color"> + <label>Background color</label> + <whatsthis>The background color for the graph</whatsthis> + <default>#FFFFFF</default> + </entry> + <entry name="zoomInStep" type="Int"> + <label>Zoom-in step</label> + <whatsthis>The value the zoom-in tool should use</whatsthis> + <default>20</default> + </entry> + <entry name="zoomOutStep" type="Int"> + <label>Zoom-out step</label> + <whatsthis>The value the zoom-out tool should use</whatsthis> + <default>25</default> + </entry> + </group> +</kcfg> diff --git a/kmplot/kmplot/kmplotIface.h b/kmplot/kmplot/kmplotIface.h new file mode 100644 index 00000000..b176b944 --- /dev/null +++ b/kmplot/kmplot/kmplotIface.h @@ -0,0 +1,56 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KMPLOTIFACE_H +#define KMPLOTIFACE_H + + +#include <dcopobject.h> +#include <kurl.h> + +/** +@author Fredrik Edemar +*/ +/// All functions in KmPlotIface are accessible with DCOP. For descriptions about the functions, see KmPlot. +class KmPlotIface : virtual public DCOPObject +{ + K_DCOP +k_dcop: + virtual void fileOpen() = 0; + virtual void setStatusBarText(const QString &text, int id) = 0; + virtual void optionsConfigureKeys() = 0; + virtual void optionsConfigureToolbars() = 0; + virtual void openFileInNewWindow(const KURL url) = 0; + virtual bool stopProgressBar() = 0; + virtual void startProgressBar(int) = 0; + virtual void increaseProgressBar() = 0; + + virtual void fileOpen(const KURL &url) = 0; +}; + + +#endif + + diff --git a/kmplot/kmplot/kmplot_part.desktop b/kmplot/kmplot/kmplot_part.desktop new file mode 100644 index 00000000..c1c1ea57 --- /dev/null +++ b/kmplot/kmplot/kmplot_part.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Icon=kmplot +Name=KmPlotPart +Name[bn]=কে-এমপ্লট-পার্ট +Name[cs]=KmPlot part +Name[et]=KmPloti komponent +Name[hi]=केएम-प्लाट-पार्ट +Name[pl]=Część osadzalna KPart programu KmPlot +Name[sv]=Kmplot-delprogram +Name[ta]=கேஎம்பிளாட்பகுதி +Name[vi]=Phần Đồ thị K +MimeType=application/x-kmplot +ServiceTypes=KParts/ReadOnlyPart +X-KDE-Library=libkmplotpart +Type=Service diff --git a/kmplot/kmplot/kmplot_part.rc b/kmplot/kmplot/kmplot_part.rc new file mode 100644 index 00000000..a90a0653 --- /dev/null +++ b/kmplot/kmplot/kmplot_part.rc @@ -0,0 +1,73 @@ +<!DOCTYPE kpartgui> +<kpartgui name="kmplot" version="6"> + <MenuBar> + <Menu name="file"> + <Action name="file_openrecent"/> + <Separator/> + <Action name="file_save"/> + <Action name="file_save_as"/> + <Action name="file_print"/> + <Separator/> + <Action name="export"/> + </Menu> + <Menu name="edit"><text>&Edit</text> + <Action name="editcolors"/> + <Action name="editaxes"/> + <Action name="editscaling"/> + <Action name="editfonts"/> + <Separator /> + <Action name="coord_i"/> + <Action name="coord_ii"/> + <Action name="coord_iii"/> + </Menu> + <Menu name="functions"><text>&Plot</text> + <Action name="newfunction"/> + <Action name="newparametric"/> + <Action name="newpolar"/> + <Action name="editplots"/> + </Menu> + <Menu name="zoom"><text>&Zoom</text> + <Action name="no_zoom"/> + <Action name="zoom_rectangular"/> + <Action name="zoom_in"/> + <Action name="zoom_out"/> + <Action name="zoom_center"/> + <Separator /> + <Action name="zoom_trig"/> + </Menu> + <Menu name="tools"><text>&Tools</text> + <Action name="yvalue"/> + <Action name="minimumvalue"/> + <Action name="maximumvalue"/> + <Action name="grapharea"/> + </Menu> + <Menu name="settings"><text>&Settings</text> + <Separator /> + <Separator /> + <Menu name="ShowSliders"><text>Show S&liders</text> + <Action name="options_configure_show_slider_0"/> + <Action name="options_configure_show_slider_1"/> + <Action name="options_configure_show_slider_2"/> + <Action name="options_configure_show_slider_3"/> + </Menu> + <Separator/> + <Action name="options_configure_keybinding"/> + <Action name="options_configure_toolbars"/> + <Action name="options_configure"/> + </Menu> + <Menu name="help"><text>&Help</text> + <Action name="names"/> + </Menu> + </MenuBar> + <ToolBar name="mainToolBar"> + <Action name="file_save"/> + <Separator /> + <Action name="quickedit"/> + <Action name="newfunction"/> + <Action name="coord_i"/> + <Action name="coord_ii"/> + <Action name="coord_iii"/> + <Action name="helpcontents"/> + </ToolBar> + +</kpartgui> diff --git a/kmplot/kmplot/kmplot_part_readonly.rc b/kmplot/kmplot/kmplot_part_readonly.rc new file mode 100644 index 00000000..fceafa84 --- /dev/null +++ b/kmplot/kmplot/kmplot_part_readonly.rc @@ -0,0 +1,54 @@ +<!DOCTYPE kpartgui> +<kpartgui name="kmplot" version="1"> + <MenuBar> + <Menu name="file"> + <Action name="file_save_as"/> + <Separator/> + <Action name="export"/> + </Menu> + <Menu name="edit"><text>&Edit</text> + <Action name="editcolors"/> + <Action name="editaxes"/> + <Action name="editscaling"/> + <Action name="editfonts"/> + <Separator /> + <Action name="coord_i"/> + <Action name="coord_ii"/> + <Action name="coord_iii"/> + </Menu> + <Menu name="zoom"><text>&Zoom</text> + <Action name="no_zoom"/> + <Action name="zoom_rectangular"/> + <Action name="zoom_in"/> + <Action name="zoom_out"/> + <Action name="zoom_center"/> + <Separator /> + <Action name="zoom_trig"/> + </Menu> + <Menu name="tools"><text>&Tools</text> + <Action name="yvalue"/> + <Action name="minimumvalue"/> + <Action name="maximumvalue"/> + <Action name="grapharea"/> + </Menu> + <Menu name="settings"><text>&Settings</text> + <Menu name="ShowSliders"><text>Show S&liders</text> + <Action name="options_configure_show_slider_0"/> + <Action name="options_configure_show_slider_1"/> + <Action name="options_configure_show_slider_2"/> + <Action name="options_configure_show_slider_3"/> + </Menu> + <Separator/> + <Action name="options_configure"/> + </Menu> + <Menu name="help"><text>&Help</text> + <Action name="names"/> + </Menu> + </MenuBar> + <ToolBar name="mainToolBar"> + <Action name="coord_i"/> + <Action name="coord_ii"/> + <Action name="coord_iii"/> + <Action name="helpcontents"/> + </ToolBar> +</kpartgui> diff --git a/kmplot/kmplot/kmplot_shell.rc b/kmplot/kmplot/kmplot_shell.rc new file mode 100644 index 00000000..10c38866 --- /dev/null +++ b/kmplot/kmplot/kmplot_shell.rc @@ -0,0 +1,43 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="kmplot_shell" version="1"> + <MenuBar> + <Menu noMerge="1" name="file"><text>&File</text> + <Action name="file_new"/> + <Separator/> + <Action name="file_open"/> + <Merge/> + <Separator/> + <Action name="file_quit"/> + </Menu> + <Merge/> + <Menu noMerge="1" name="settings"><text>&Settings</text> + <!--<Action name="options_show_toolbar"/>--> + <Merge name="StandardToolBarMenuHandler" /> + <Action name="options_show_statusbar"/> + <Separator/> + <Action name="fullscreen" /> + <Merge/> +<!-- <Separator/> + <Action name="options_configure_keybinding"/> + <Action name="options_configure_toolbars"/> + <Action name="options_configure"/>--> + <Separator/> + </Menu> + <Menu name="help" noMerge="1"><text>&Help</text> + <Action name="help_contents"/> + <Action name="help_whats_this"/> + <Separator/> + <Merge/> + <Separator/> + <Action name="help_report_bug"/> + <Separator/> + <Action name="help_about_app"/> + <Action name="help_about_kde"/> + </Menu> + </MenuBar> + <ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text> + <Action name="file_new"/> + <Action name="file_open"/> + <Merge/> + </ToolBar> +</kpartgui>
\ No newline at end of file diff --git a/kmplot/kmplot/kmplotio.cpp b/kmplot/kmplot/kmplotio.cpp new file mode 100644 index 00000000..1af28e25 --- /dev/null +++ b/kmplot/kmplot/kmplotio.cpp @@ -0,0 +1,614 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +// Qt includes +#include <qdom.h> +#include <qfile.h> + +// KDE includes +#include <kio/netaccess.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <ktempfile.h> + +// ANSI-C includes +#include <stdlib.h> + +// local includes +#include "kmplotio.h" +#include "MainDlg.h" +#include "settings.h" + +class XParser; + +KmPlotIO::KmPlotIO( XParser *parser) + : m_parser(parser) +{} + + +KmPlotIO::~KmPlotIO() +{} + +bool KmPlotIO::save( const KURL &url ) +{ + // saving as xml by a QDomDocument + QDomDocument doc( "kmpdoc" ); + // the root tag + QDomElement root = doc.createElement( "kmpdoc" ); + root.setAttribute( "version", "2" ); + doc.appendChild( root ); + + // the axes tag + QDomElement tag = doc.createElement( "axes" ); + + tag.setAttribute( "color", Settings::axesColor().name() ); + tag.setAttribute( "width", Settings::axesLineWidth() ); + tag.setAttribute( "tic-width", Settings::ticWidth() ); + tag.setAttribute( "tic-legth", Settings::ticLength() ); + + addTag( doc, tag, "show-axes", Settings::showAxes() ? "1" : "-1" ); + addTag( doc, tag, "show-arrows", Settings::showArrows() ? "1" : "-1" ); + addTag( doc, tag, "show-label", Settings::showLabel() ? "1" : "-1" ); + addTag( doc, tag, "show-frame", Settings::showExtraFrame() ? "1" : "-1" ); + addTag( doc, tag, "show-extra-frame", Settings::showExtraFrame() ? "1" : "-1" ); + + addTag( doc, tag, "xcoord", QString::number( Settings::xRange() ) ); + if( Settings::xRange() == 4 ) // custom plot range + { + addTag( doc, tag, "xmin", Settings::xMin() ); + addTag( doc, tag, "xmax", Settings::xMax() ); + } + + addTag( doc, tag, "ycoord", QString::number( Settings::yRange() ) ); + if( Settings::yRange() == 4 ) // custom plot range + { + addTag( doc, tag, "ymin", Settings::yMin() ); + addTag( doc, tag, "ymax", Settings::yMax() ); + } + + root.appendChild( tag ); + + tag = doc.createElement( "grid" ); + + tag.setAttribute( "color", Settings::gridColor().name() ); + tag.setAttribute( "width", Settings::gridLineWidth() ); + + addTag( doc, tag, "mode", QString::number( Settings::gridStyle() ) ); + + root.appendChild( tag ); + + tag = doc.createElement( "scale" ); + + QString temp; + temp.setNum(Settings::xScaling()); + addTag( doc, tag, "tic-x", temp ); + temp.setNum(Settings::yScaling()); + addTag( doc, tag, "tic-y", temp ); + temp.setNum(Settings::xPrinting()); + addTag( doc, tag, "print-tic-x", temp ); + temp.setNum(Settings::yPrinting()); + addTag( doc, tag, "print-tic-y", temp); + + root.appendChild( tag ); + + + for( QValueVector<Ufkt>::iterator it = m_parser->ufkt.begin(); it != m_parser->ufkt.end(); ++it) + { + if ( !it->fstr.isEmpty() ) + { + tag = doc.createElement( "function" ); + + //tag.setAttribute( "number", ix ); + tag.setAttribute( "visible", it->f_mode ); + tag.setAttribute( "color", QColor( it->color ).name() ); + tag.setAttribute( "width", it->linewidth ); + tag.setAttribute( "use-slider", it->use_slider ); + + if ( it->f1_mode) + { + tag.setAttribute( "visible-deriv", it->f1_mode ); + tag.setAttribute( "deriv-color", QColor( it->f1_color ).name() ); + tag.setAttribute( "deriv-width", it->f1_linewidth ); + } + + if ( it->f2_mode) + { + tag.setAttribute( "visible-2nd-deriv", it->f2_mode ); + tag.setAttribute( "deriv2nd-color", QColor( it->f2_color ).name() ); + tag.setAttribute( "deriv2nd-width", it->f2_linewidth ); + } + + if ( it->integral_mode) + { + tag.setAttribute( "visible-integral", "1" ); + tag.setAttribute( "integral-color", QColor( it->integral_color ).name() ); + tag.setAttribute( "integral-width", it->integral_linewidth ); + tag.setAttribute( "integral-use-precision", it->integral_use_precision ); + tag.setAttribute( "integral-precision", it->integral_precision ); + tag.setAttribute( "integral-startx", it->str_startx ); + tag.setAttribute( "integral-starty", it->str_starty ); + } + + addTag( doc, tag, "equation", it->fstr ); + + QStringList str_parameters; + for ( QValueList<ParameterValueItem>::Iterator k = it->parameters.begin(); k != it->parameters.end(); ++k ) + str_parameters.append( (*k).expression); + + if( !str_parameters.isEmpty() ) + addTag( doc, tag, "parameterlist", str_parameters.join( ";" ) ); + + if (it->usecustomxmin) + addTag( doc, tag, "arg-min", it->str_dmin ); + if (it->usecustomxmax) + addTag( doc, tag, "arg-max", it->str_dmax ); + + root.appendChild( tag ); + + } + } + + tag = doc.createElement( "fonts" ); + addTag( doc, tag, "axes-font", Settings::axesFont() ); + addTag( doc, tag, "header-table-font", Settings::headerTableFont() ); + root.appendChild( tag ); + + QFile xmlfile; + if (!url.isLocalFile() ) + { + KTempFile tmpfile; + xmlfile.setName(tmpfile.name() ); + if (!xmlfile.open( IO_WriteOnly ) ) + { + tmpfile.unlink(); + return false; + } + QTextStream ts( &xmlfile ); + doc.save( ts, 4 ); + xmlfile.close(); + + if ( !KIO::NetAccess::upload(tmpfile.name(), url,0)) + { + tmpfile.unlink(); + return false; + } + tmpfile.unlink(); + } + else + { + xmlfile.setName(url.prettyURL(0,KURL::StripFileProtocol) ); + if (!xmlfile.open( IO_WriteOnly ) ) + return false; + QTextStream ts( &xmlfile ); + doc.save( ts, 4 ); + xmlfile.close(); + return true; + } + return true; + +} + +void KmPlotIO::addTag( QDomDocument &doc, QDomElement &parentTag, const QString tagName, const QString tagValue ) +{ + QDomElement tag = doc.createElement( tagName ); + QDomText value = doc.createTextNode( tagValue ); + tag.appendChild( value ); + parentTag.appendChild( tag ); +} + +bool KmPlotIO::load( const KURL &url ) +{ + QDomDocument doc( "kmpdoc" ); + QFile f; + if ( !url.isLocalFile() ) + { + if( !KIO::NetAccess::exists( url, true, 0 ) ) + { + KMessageBox::error(0,i18n("The file does not exist.")); + return false; + } + QString tmpfile; + if( !KIO::NetAccess::download( url, tmpfile, 0 ) ) + { + KMessageBox::error(0,i18n("An error appeared when opening this file")); + return false; + } + f.setName(tmpfile); + } + else + f.setName( url.prettyURL(0,KURL::StripFileProtocol) ); + + if ( !f.open( IO_ReadOnly ) ) + { + KMessageBox::error(0,i18n("An error appeared when opening this file")); + return false; + } + if ( !doc.setContent( &f ) ) + { + KMessageBox::error(0,i18n("The file could not be loaded")); + f.close(); + return false; + } + f.close(); + + QDomElement element = doc.documentElement(); + QString version = element.attribute( "version" ); + if ( version.isNull()) //an old kmplot-file + { + MainDlg::oldfileversion = true; + for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + { + if ( n.nodeName() == "axes" ) + oldParseAxes( n.toElement() ); + if ( n.nodeName() == "grid" ) + parseGrid( n.toElement() ); + if ( n.nodeName() == "scale" ) + oldParseScale( n.toElement() ); + if ( n.nodeName() == "function" ) + oldParseFunction( m_parser, n.toElement() ); + } + } + else if (version == "1" || version == "2") + { + MainDlg::oldfileversion = false; + for ( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) + { + if ( n.nodeName() == "axes" ) + parseAxes( n.toElement() ); + if ( n.nodeName() == "grid" ) + parseGrid( n.toElement() ); + if ( n.nodeName() == "scale" ) + parseScale( n.toElement() ); + if ( n.nodeName() == "function") + parseFunction( m_parser, n.toElement() ); + } + } + else + KMessageBox::error(0,i18n("The file had an unknown version number")); + + if ( !url.isLocalFile() ) + KIO::NetAccess::removeTempFile( f.name() ); + return true; +} + +void KmPlotIO::parseAxes( const QDomElement &n ) +{ + Settings::setAxesLineWidth( n.attribute( "width", "1" ).toInt() ); + Settings::setAxesColor( QColor( n.attribute( "color", "#000000" ) ) ); + Settings::setTicWidth( n.attribute( "tic-width", "3" ).toInt() ); + Settings::setTicLength( n.attribute( "tic-length", "10" ).toInt() ); + + Settings::setShowAxes( n.namedItem( "show-axes" ).toElement().text().toInt() == 1 ); + Settings::setShowArrows( n.namedItem( "show-arrows" ).toElement().text().toInt() == 1 ); + Settings::setShowLabel( n.namedItem( "show-label" ).toElement().text().toInt() == 1 ); + Settings::setShowFrame( n.namedItem( "show-frame" ).toElement().text().toInt() == 1 ); + Settings::setShowExtraFrame( n.namedItem( "show-extra-frame" ).toElement().text().toInt() == 1 ); + Settings::setXRange( n.namedItem( "xcoord" ).toElement().text().toInt() ); + Settings::setXMin( n.namedItem( "xmin" ).toElement().text() ); + Settings::setXMax( n.namedItem( "xmax" ).toElement().text() ); + Settings::setYRange( n.namedItem( "ycoord" ).toElement().text().toInt() ); + Settings::setYMin( n.namedItem( "ymin" ).toElement().text() ); + Settings::setYMax( n.namedItem( "ymax" ).toElement().text() ); +} + +void KmPlotIO::parseGrid( const QDomElement & n ) +{ + Settings::setGridColor( QColor( n.attribute( "color", "#c0c0c0" ) ) ); + Settings::setGridLineWidth( n.attribute( "width", "1" ).toInt() ); + + Settings::setGridStyle( n.namedItem( "mode" ).toElement().text().toInt() ); +} + +int unit2index( const QString unit ) +{ + QString units[ 9 ] = { "10", "5", "2", "1", "0.5", "pi/2", "pi/3", "pi/4",i18n("automatic") }; + int index = 0; + while( ( index < 9 ) && ( unit!= units[ index ] ) ) index ++; + if( index == 9 ) index = -1; + return index; +} + + +void KmPlotIO::parseScale(const QDomElement & n ) +{ + Settings::setXScaling( n.namedItem( "tic-x" ).toElement().text().toInt() ); + Settings::setYScaling( n.namedItem( "tic-y" ).toElement().text().toInt() ); + Settings::setXPrinting( n.namedItem( "print-tic-x" ).toElement().text().toInt() ); + Settings::setYPrinting( n.namedItem( "print-tic-y" ).toElement().text().toInt() ); +} + +void KmPlotIO::parseFunction( XParser *m_parser, const QDomElement & n ) +{ + QString temp; + Ufkt ufkt; + m_parser->prepareAddingFunction(&ufkt); + int const next_index=m_parser->getNextIndex()+1; + + ufkt.f_mode = n.attribute( "visible" ).toInt(); + ufkt.color = QColor( n.attribute( "color" ) ).rgb(); + ufkt.linewidth = n.attribute( "width" ).toInt(); + ufkt.use_slider = n.attribute( "use-slider" ).toInt(); + + temp = n.attribute( "visible-deriv" ); + if (!temp.isNull()) + { + ufkt.f1_mode = temp.toInt(); + ufkt.f1_color = QColor(n.attribute( "deriv-color" )).rgb(); + ufkt.f1_linewidth = n.attribute( "deriv-width" ).toInt(); + } + else + { + ufkt.f1_mode = 0; + ufkt.f1_color = m_parser->defaultColor(next_index); + ufkt.f1_linewidth = m_parser->linewidth0; + } + + temp = n.attribute( "visible-2nd-deriv" ); + if (!temp.isNull()) + { + ufkt.f2_mode = temp.toInt(); + ufkt.f2_color = QColor(n.attribute( "deriv2nd-color" )).rgb(); + ufkt.f2_linewidth = n.attribute( "deriv2nd-width" ).toInt(); + } + else + { + ufkt.f2_mode = 0; + ufkt.f2_color = m_parser->defaultColor(next_index); + ufkt.f2_linewidth = m_parser->linewidth0; + } + + temp = n.attribute( "visible-integral" ); + if (!temp.isNull()) + { + ufkt.integral_mode = temp.toInt(); + ufkt.integral_color = QColor(n.attribute( "integral-color" )).rgb(); + ufkt.integral_linewidth = n.attribute( "integral-width" ).toInt(); + ufkt.integral_use_precision = n.attribute( "integral-use-precision" ).toInt(); + ufkt.integral_precision = n.attribute( "integral-precision" ).toInt(); + ufkt.str_startx = n.attribute( "integral-startx" ); + ufkt.startx = m_parser->eval( ufkt.str_startx ); + ufkt.str_starty = n.attribute( "integral-starty" ); + ufkt.starty = m_parser->eval( ufkt.str_starty ); + + } + else + { + ufkt.integral_mode = 0; + ufkt.integral_color = m_parser->defaultColor(next_index); + ufkt.integral_linewidth = m_parser->linewidth0; + ufkt.integral_use_precision = 0; + ufkt.integral_precision = ufkt.linewidth; + } + + ufkt.str_dmin = n.namedItem( "arg-min" ).toElement().text(); + if( ufkt.str_dmin.isEmpty() ) + ufkt.usecustomxmin = false; + else + { + ufkt.usecustomxmin = true; + ufkt.dmin = m_parser->eval( ufkt.str_dmin ); + + } + ufkt.str_dmax = n.namedItem( "arg-max" ).toElement().text(); + if( ufkt.str_dmax.isEmpty() ) + ufkt.usecustomxmax = false; + else + { + ufkt.usecustomxmax = true; + ufkt.dmax = m_parser->eval( ufkt.str_dmax ); + } + + if (ufkt.usecustomxmin && ufkt.usecustomxmax && ufkt.str_dmin==ufkt.str_dmax) + { + ufkt.usecustomxmin = false; + ufkt.usecustomxmax = false; + } + + ufkt.fstr = n.namedItem( "equation" ).toElement().text(); + if (MainDlg::oldfileversion) + parseThreeDotThreeParameters( m_parser, n, ufkt ); + else + parseParameters( m_parser, n, ufkt ); + + QString fstr = ufkt.fstr; + if ( !fstr.isEmpty() ) + { + int const i = fstr.find( ';' ); + QString str; + if ( i == -1 ) + str = fstr; + else + str = fstr.left( i ); + m_parser->addfkt( str ); + Ufkt *added_function = &m_parser->ufkt.last(); + added_function->f_mode = ufkt.f_mode; + added_function->f1_mode = ufkt.f1_mode; + added_function->f2_mode = ufkt.f2_mode; + added_function->integral_mode = ufkt.integral_mode; + added_function->integral_use_precision = ufkt.integral_use_precision; + added_function->linewidth = ufkt.linewidth; + added_function->f1_linewidth = ufkt.f1_linewidth; + added_function->f2_linewidth = ufkt.f2_linewidth; + added_function->integral_linewidth = ufkt.integral_linewidth; + added_function->str_dmin = ufkt.str_dmin; + added_function->str_dmax = ufkt.str_dmax; + added_function->dmin = ufkt.dmin; + added_function->dmax = ufkt.dmax; + added_function->str_startx = ufkt.str_startx; + added_function->str_starty = ufkt.str_starty; + added_function->oldx = ufkt.oldx; + added_function->starty = ufkt.starty; + added_function->startx = ufkt.startx; + added_function->integral_precision = ufkt.integral_precision; + added_function->color = ufkt.color; + added_function->f1_color = ufkt.f1_color; + added_function->f2_color = ufkt.f2_color; + added_function->integral_color = ufkt.integral_color; + added_function->parameters = ufkt.parameters; + added_function->use_slider = ufkt.use_slider; + added_function->usecustomxmin = ufkt.usecustomxmin; + added_function->usecustomxmax = ufkt.usecustomxmax; + } +} + +void KmPlotIO::parseParameters( XParser *m_parser, const QDomElement &n, Ufkt &ufkt ) +{ + QStringList str_parameters; + for ( QValueList<ParameterValueItem>::Iterator it = ufkt.parameters.begin(); it != ufkt.parameters.end(); ++it ) + str_parameters.append( (*it).expression); + str_parameters = QStringList::split( ";", n.namedItem( "parameterlist" ).toElement().text() ); + for( QStringList::Iterator it = str_parameters.begin(); it != str_parameters.end(); ++it ) + ufkt.parameters.append( ParameterValueItem( *it, m_parser->eval( *it ) )); +} + +void KmPlotIO::parseThreeDotThreeParameters( XParser *m_parser, const QDomElement &n, Ufkt &ufkt ) +{ + QStringList str_parameters; + for ( QValueList<ParameterValueItem>::Iterator it = ufkt.parameters.begin(); it != ufkt.parameters.end(); ++it ) + str_parameters.append( (*it).expression); + str_parameters = QStringList::split( ",", n.namedItem( "parameterlist" ).toElement().text() ); + for( QStringList::Iterator it = str_parameters.begin(); it != str_parameters.end(); ++it ) + ufkt.parameters.append( ParameterValueItem( *it, m_parser->eval( *it ) )); +} + +void KmPlotIO::oldParseFunction( XParser *m_parser, const QDomElement & n ) +{ + kdDebug() << "parsing old function" << endl; + Ufkt ufkt; + m_parser->prepareAddingFunction(&ufkt); + + ufkt.f_mode = n.attribute( "visible" ).toInt(); + ufkt.f1_mode = n.attribute( "visible-deriv" ).toInt(); + ufkt.f2_mode = n.attribute( "visible-2nd-deriv" ).toInt(); + ufkt.f2_mode = 0; + ufkt.linewidth = n.attribute( "width" ).toInt(); + ufkt.use_slider = -1; + ufkt.color = ufkt.f1_color = ufkt.f2_color = ufkt.integral_color = QColor( n.attribute( "color" ) ).rgb(); + + ufkt.str_dmin = n.namedItem( "arg-min" ).toElement().text(); + if( ufkt.str_dmin.isEmpty() ) + ufkt.usecustomxmin = false; + else + { + ufkt.dmin = m_parser->eval( ufkt.str_dmin ); + ufkt.usecustomxmin = true; + } + ufkt.str_dmax = n.namedItem( "arg-max" ).toElement().text(); + if( ufkt.str_dmax.isEmpty() ) + ufkt.usecustomxmax = false; + else + { + ufkt.dmax = m_parser->eval( ufkt.str_dmax ); + ufkt.usecustomxmax = true; + } + if (ufkt.usecustomxmin && ufkt.usecustomxmax && ufkt.str_dmin==ufkt.str_dmax) + { + ufkt.usecustomxmin = false; + ufkt.usecustomxmax = false; + } + + const QString tmp_fstr = n.namedItem( "equation" ).toElement().text(); + const int pos = tmp_fstr.find(';'); + if ( pos == -1 ) + ufkt.fstr = tmp_fstr; + else + { + ufkt.fstr = tmp_fstr.left(pos); + if ( !m_parser->getext( &ufkt, tmp_fstr) ) + { + KMessageBox::error(0,i18n("The function %1 could not be loaded").arg(ufkt.fstr)); + return; + } + } + + QString fstr = ufkt.fstr; + if ( !fstr.isEmpty() ) + { + int const i = fstr.find( ';' ); + QString str; + if ( i == -1 ) + str = fstr; + else + str = fstr.left( i ); + m_parser->addfkt( str ); + Ufkt *added_function = &m_parser->ufkt.last(); + added_function->f_mode = ufkt.f_mode; + added_function->f1_mode = ufkt.f1_mode; + added_function->f2_mode = ufkt.f2_mode; + added_function->integral_mode = ufkt.integral_mode; + added_function->integral_use_precision = ufkt.integral_use_precision; + added_function->linewidth = ufkt.linewidth; + added_function->f1_linewidth = ufkt.f1_linewidth; + added_function->f2_linewidth = ufkt.f2_linewidth; + added_function->integral_linewidth = ufkt.integral_linewidth; + added_function->str_dmin = ufkt.str_dmin; + added_function->str_dmax = ufkt.str_dmax; + added_function->dmin = ufkt.dmin; + added_function->dmax = ufkt.dmax; + added_function->str_startx = ufkt.str_startx; + added_function->str_starty = ufkt.str_starty; + added_function->oldx = ufkt.oldx; + added_function->starty = ufkt.starty; + added_function->startx = ufkt.startx; + added_function->integral_precision = ufkt.integral_precision; + added_function->color = ufkt.color; + added_function->f1_color = ufkt.f1_color; + added_function->f2_color = ufkt.f2_color; + added_function->integral_color = ufkt.integral_color; + added_function->parameters = ufkt.parameters; + added_function->use_slider = ufkt.use_slider; + added_function->usecustomxmin = ufkt.usecustomxmin; + added_function->usecustomxmax = ufkt.usecustomxmax; + } +} + +void KmPlotIO::oldParseAxes( const QDomElement &n ) +{ + Settings::setAxesLineWidth( n.attribute( "width", "1" ).toInt() ); + Settings::setAxesColor( QColor( n.attribute( "color", "#000000" ) ) ); + Settings::setTicWidth( n.attribute( "tic-width", "3" ).toInt() ); + Settings::setTicLength( n.attribute( "tic-length", "10" ).toInt() ); + + Settings::setShowAxes( true ); + Settings::setShowArrows( true ); + Settings::setShowLabel( true ); + Settings::setShowFrame( true ); + Settings::setShowExtraFrame( true ); + Settings::setXRange( n.namedItem( "xcoord" ).toElement().text().toInt() ); + Settings::setXMin( n.namedItem( "xmin" ).toElement().text() ); + Settings::setXMax( n.namedItem( "xmax" ).toElement().text() ); + Settings::setYRange( n.namedItem( "ycoord" ).toElement().text().toInt() ); + Settings::setYMin( n.namedItem( "ymin" ).toElement().text() ); + Settings::setYMax( n.namedItem( "ymax" ).toElement().text() ); +} + +void KmPlotIO::oldParseScale( const QDomElement & n ) +{ + Settings::setXScaling( unit2index( n.namedItem( "tic-x" ).toElement().text() ) ); + Settings::setYScaling( unit2index( n.namedItem( "tic-y" ).toElement().text() ) ); + Settings::setXPrinting( unit2index( n.namedItem( "print-tic-x" ).toElement().text() ) ); + Settings::setYPrinting( unit2index( n.namedItem( "print-tic-y" ).toElement().text() ) ); +} + diff --git a/kmplot/kmplot/kmplotio.h b/kmplot/kmplot/kmplotio.h new file mode 100644 index 00000000..837cf4ec --- /dev/null +++ b/kmplot/kmplot/kmplotio.h @@ -0,0 +1,103 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KMPLOTIO_H +#define KMPLOTIO_H + +#include <kurl.h> +#include "xparser.h" + +class QString; +class XParser; + +/** @short This class manages the file operations load and save. + * + * @author Klaus-Dieter Möller & Matthias Meßmer + */ +class KmPlotIO +{ + public: + /// Nothing to do here; only static functions needed. + KmPlotIO( XParser *parser); + /// Empty. + ~KmPlotIO(); + + /** + * Store all information about the current saved plot in a xml file with the .fkt extension + * in the filename file. + * @param url Name (URL) of the file which will be saved. + */ + bool save( const KURL &url ); + + /** + * Read a kmpdoc xml file to restaure the settings of a previously saved plot + * @param url Name (URL) of file which will be opened + */ + bool load( const KURL &url ); + + private: + /** Esay way to add a tag to the Dom tree + * @param &doc The document. + * @param parentTag The parent tag to support encapsulated tags. + * @param tagName The Name of the tag. + * @param tagValue The data between the opening and cloding tag. + */ + void addTag( QDomDocument &doc, QDomElement &parentTag, const QString tagName, const QString tagValue ); + /// Reads axes parameters from the node @a n. + /// @param n Node containing the options. + void parseAxes( const QDomElement &n ); + /// Reads grid parameters from the node @a n. + /// @param n Node containing the options. + void parseGrid( const QDomElement &n ); + /// Reads scale parameters from the node @a n. + /// @param n Node containing the options. + void parseScale( const QDomElement &n ); + /// Reads function parameters from the node @a n. + /// @param parser points to the parser instance. + /// @param n Node containing the options. + void parseFunction( XParser *parser, const QDomElement &n ); + /// Reads parameter values for a function from the node @a n. + /// @param parser points to the parser instance. + /// @param n Node containing the options. + /// @param ix Function index in the parser instance + void parseParameters( XParser *parser, const QDomElement &n, Ufkt &ufkt); + + /// For KDE 3.3 + void parseThreeDotThreeParameters( XParser *parser, const QDomElement &n, Ufkt &ufkt); + + ///For KDE <3.3 + /// This is the same as parseScale but is made for old Kmplot-files + void oldParseScale( const QDomElement & n ); + /// This is the same as parseFunction but is made for old Kmplot-files + void oldParseFunction( XParser *parser, const QDomElement &n ); + /// This is the same as parseAxes but is made for old Kmplot-files + void oldParseAxes( const QDomElement &n ); + + XParser *m_parser; + +}; + +#endif + diff --git a/kmplot/kmplot/kmplotprogress.cpp b/kmplot/kmplot/kmplotprogress.cpp new file mode 100644 index 00000000..721480e0 --- /dev/null +++ b/kmplot/kmplot/kmplotprogress.cpp @@ -0,0 +1,56 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include <kiconloader.h> +#include <kprogress.h> + +#include "kmplotprogress.h" +//#include "kmplotprogress.moc.cpp" + +KmPlotProgress::KmPlotProgress( QWidget* parent, const char* name ) : QWidget( parent, name) +{ + button = new KPushButton(this); + button->setPixmap( SmallIcon( "cancel" ) ); + button->setGeometry( QRect( 0, 0, 30, 23 ) ); + button->setMaximumHeight(height()-10); + + progress = new KProgress(this); + progress->setGeometry( QRect( 30, 0, 124, 23 ) ); + progress->setMaximumHeight(height()-10); + + hide(); + setMinimumWidth(154); +} + +KmPlotProgress::~KmPlotProgress() +{ +} + +void KmPlotProgress::increase() +{ + progress->setProgress( progress->progress()+1); +} + +#include "kmplotprogress.moc" diff --git a/kmplot/kmplot/kmplotprogress.h b/kmplot/kmplot/kmplotprogress.h new file mode 100644 index 00000000..dc7bb166 --- /dev/null +++ b/kmplot/kmplot/kmplotprogress.h @@ -0,0 +1,45 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ +#ifndef kmplotprogress_included +#define kmplotprogress_included + +#include <kprogress.h> +#include <kpushbutton.h> +#include <qwidget.h> + +/// The progress-widget in the statusbar which appears when drawing integrals +class KmPlotProgress: public QWidget +{ + Q_OBJECT +public: + KmPlotProgress( QWidget* parent = 0, const char* name = 0 ); + ~KmPlotProgress(); + void increase(); + + KPushButton *button; + KProgress *progress; +}; + +#endif // kmplotprogress_included diff --git a/kmplot/kmplot/kparametereditor.cpp b/kmplot/kmplot/kparametereditor.cpp new file mode 100644 index 00000000..95b4a0c5 --- /dev/null +++ b/kmplot/kmplot/kparametereditor.cpp @@ -0,0 +1,298 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + + +#include <kdebug.h> +#include <kfiledialog.h> +#include <kinputdialog.h> +#include <kio/netaccess.h> +#include <klistbox.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpushbutton.h> +#include <ktempfile.h> +#include <kurl.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qvaluelist.h> + +#include "kparametereditor.h" + +class ParameterValueList; + +KParameterEditor::KParameterEditor(XParser *m, QValueList<ParameterValueItem> *l, QWidget *parent, const char *name) + : QParameterEditor(parent,name, true, Qt::WDestructiveClose), m_parameter(l), m_parser(m) +{ + for ( QValueList<ParameterValueItem>::Iterator it = m_parameter->begin(); it != m_parameter->end(); ++it ) + list->insertItem( (*it).expression ); + list->sort(); + + connect( cmdNew, SIGNAL( clicked() ), this, SLOT( cmdNew_clicked() )); + connect( cmdEdit, SIGNAL( clicked() ), this, SLOT( cmdEdit_clicked() )); + connect( cmdDelete, SIGNAL( clicked() ), this, SLOT( cmdDelete_clicked() )); + connect( cmdImport, SIGNAL( clicked() ), this, SLOT( cmdImport_clicked() )); + connect( cmdExport, SIGNAL( clicked() ), this, SLOT( cmdExport_clicked() )); + connect( cmdClose, SIGNAL( clicked() ), this, SLOT( close() )); + connect( list, SIGNAL( doubleClicked( QListBoxItem * ) ), this, SLOT( varlist_doubleClicked( QListBoxItem *) )); + connect( list, SIGNAL( clicked ( QListBoxItem * ) ), this, SLOT( varlist_clicked(QListBoxItem * ) )); + +} + +KParameterEditor::~KParameterEditor() +{ + m_parameter->clear(); + QString item_text; + for (int i = 0; (uint)i <= list->count();i++) + { + item_text = list->text(i); + if ( !item_text.isEmpty() ) + m_parameter->append( ParameterValueItem(item_text, m_parser->eval( item_text)) ); + } +} + +void KParameterEditor::cmdNew_clicked() +{ + QString result=""; + while (1) + { + bool ok; + result = KInputDialog::getText( i18n("Parameter Value"), i18n( "Enter a new parameter value:" ), result, &ok ); + if ( !ok) + return; + m_parser->eval( result ); + if ( m_parser->parserError(false) != 0 ) + { + m_parser->parserError(); + continue; + } + if ( checkTwoOfIt(result) ) + { + KMessageBox::error(0,i18n("The value %1 already exists and will therefore not be added.").arg(result)); + continue; + } + list->insertItem(result); + list->sort(); + break; + } +} + +void KParameterEditor::cmdEdit_clicked() +{ + QString result=list->currentText(); + while (1) + { + bool ok; + result = KInputDialog::getText( i18n("Parameter Value"), i18n( "Enter a new parameter value:" ), result, &ok ); + if ( !ok) + return; + m_parser->eval(result); + if ( m_parser->parserError(false) != 0) + { + m_parser->parserError(); + continue; + } + if ( checkTwoOfIt(result) ) + { + if( result != list->currentText() ) + KMessageBox::error(0,i18n("The value %1 already exists.").arg(result)); + continue; + } + list->removeItem( list->currentItem()); + list->insertItem(result); + list->sort(); + break; + } +} + +void KParameterEditor::cmdDelete_clicked() +{ + list->removeItem( list->currentItem()); + list->sort(); +} + +void KParameterEditor::cmdImport_clicked() +{ + KURL url = KFileDialog::getOpenURL( QString::null,i18n("*.txt|Plain Text File ")); + if ( url.isEmpty() ) + return; + + if (!KIO::NetAccess::exists(url,true,this) ) + { + KMessageBox::error(0,i18n("The file does not exist.")); + return; + } + + bool verbose = false; + QFile file; + QString tmpfile; + if ( !url.isLocalFile() ) + { + if ( !KIO::NetAccess::download(url, tmpfile, this) ) + { + KMessageBox::error(0,i18n("An error appeared when opening this file")); + return; + } + file.setName(tmpfile); + } + else + file.setName(url.prettyURL(0,KURL::StripFileProtocol) ); + + if ( file.open(IO_ReadOnly) ) + { + QTextStream stream(&file); + QString line; + for( int i=1; !stream.atEnd();i++ ) + { + line = stream.readLine(); + if (line.isEmpty()) + continue; + m_parser->eval( line ); + if ( m_parser->parserError(false) == 0) + { + if ( !checkTwoOfIt(line) ) + { + list->insertItem(line); + list->sort(); + } + } + else if ( !verbose) + { + if ( KMessageBox::warningContinueCancel(this,i18n("Line %1 is not a valid parameter value and will therefore not be included. Do you want to continue?").arg(i) ) == KMessageBox::Cancel) + { + file.close(); + KIO::NetAccess::removeTempFile( tmpfile ); + return; + } + else if (KMessageBox::warningYesNo(this,i18n("Would you like to be informed about other lines that cannot be read?"), QString::null, i18n("Get Informed"), i18n("Ignore Information") ) == KMessageBox::No) + verbose = true; + } + } + file.close(); + } + else + KMessageBox::error(0,i18n("An error appeared when opening this file")); + + if ( !url.isLocalFile() ) + KIO::NetAccess::removeTempFile( tmpfile ); +} + +void KParameterEditor::cmdExport_clicked() +{ + if ( !list->count() ) + return; + KURL url = KFileDialog::getSaveURL( QString::null,i18n("*.txt|Plain Text File ")); + if ( url.isEmpty() ) + return; + + if( !KIO::NetAccess::exists( url,false,this ) || KMessageBox::warningContinueCancel( this, i18n( "A file named \"%1\" already exists. Are you sure you want to continue and overwrite this file?" ).arg( url.url()), i18n( "Overwrite File?" ), KGuiItem( i18n( "&Overwrite" ) ) ) == KMessageBox::Continue ) + { + QString tmpfile; + QFile file; + if ( !url.isLocalFile() ) + { + KTempFile tmpfile; + file.setName(tmpfile.name() ); + + if (file.open( IO_WriteOnly ) ) + { + QTextStream stream(&file); + QListBoxItem *it = list->firstItem(); + while ( 1 ) + { + stream << it->text(); + it = it->next(); + if (it) + stream << endl; //only write a new line if there are more text + else + break; + } + file.close(); + } + else + KMessageBox::error(0,i18n("An error appeared when saving this file")); + + if ( !KIO::NetAccess::upload(tmpfile.name(),url, this) ) + { + KMessageBox::error(0,i18n("An error appeared when saving this file")); + tmpfile.unlink(); + return; + } + tmpfile.unlink(); + } + else + { + file.setName(url.prettyURL(0,KURL::StripFileProtocol)); + if (file.open( IO_WriteOnly ) ) + { + QTextStream stream(&file); + QListBoxItem *it = list->firstItem(); + while ( 1 ) + { + stream << it->text(); + it = it->next(); + if (it) + stream << endl; //only write a new line if there are more text + else + break; + } + file.close(); + } + else + KMessageBox::error(0,i18n("An error appeared when saving this file")); + } + } + + +} + +void KParameterEditor::varlist_clicked( QListBoxItem * item ) +{ + if (item) + { + cmdEdit->setEnabled(true); + cmdDelete->setEnabled(true); + } + else + { + cmdEdit->setEnabled(false); + cmdDelete->setEnabled(false); + } +} + + +void KParameterEditor::varlist_doubleClicked( QListBoxItem * ) +{ + cmdEdit_clicked(); +} + +bool KParameterEditor::checkTwoOfIt(const QString & text) +{ + if ( list->findItem(text,Qt::ExactMatch) == 0) + return false; + else + return true; +} + +#include "kparametereditor.moc" diff --git a/kmplot/kmplot/kparametereditor.h b/kmplot/kmplot/kparametereditor.h new file mode 100644 index 00000000..223ce5b8 --- /dev/null +++ b/kmplot/kmplot/kparametereditor.h @@ -0,0 +1,62 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KPARAMETEREDITOR_H +#define KPARAMETEREDITOR_H + +#include "qparametereditor.h" +#include "xparser.h" + +class ParameterValueList; + +/** +@author Fredrik Edemar +*/ +/// This class handles the parameter values: it can create, remove, edit and import values. +class KParameterEditor : public QParameterEditor +{ +Q_OBJECT +public: + KParameterEditor(XParser *, QValueList<ParameterValueItem> *, QWidget *parent = 0, const char *name = 0); + ~KParameterEditor(); + +public slots: + void cmdNew_clicked(); + void cmdEdit_clicked(); + void cmdDelete_clicked(); + void cmdImport_clicked(); + void cmdExport_clicked(); + void varlist_clicked( QListBoxItem * ); + void varlist_doubleClicked( QListBoxItem * ); + + +private: + /// Check so that it doesn't exist two equal values + bool checkTwoOfIt( const QString & text); + QValueList<ParameterValueItem> *m_parameter; + XParser *m_parser; +}; + +#endif diff --git a/kmplot/kmplot/kprinterdlg.cpp b/kmplot/kmplot/kprinterdlg.cpp new file mode 100644 index 00000000..f17308e0 --- /dev/null +++ b/kmplot/kmplot/kprinterdlg.cpp @@ -0,0 +1,71 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +// Qt includes +#include <qlayout.h> + +// KDE includes +#include <kdialog.h> +#include <klocale.h> + +// local includes +#include "kprinterdlg.h" + +KPrinterDlg::KPrinterDlg( QWidget *parent, const char *name ) + : KPrintDialogPage( parent, name ) +{ + setTitle( i18n( "KmPlot Options" ) ); + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->setMargin( KDialog::marginHint() ); + layout->setSpacing( KDialog::spacingHint() ); + + + printHeaderTable = new QCheckBox( i18n( "Print header table" ), this ); + transparent_background = new QCheckBox( i18n( "Transparent background" ), this ); + layout->addWidget( printHeaderTable ); + layout->addWidget( transparent_background ); + layout->addStretch( 1 ); +} + +void KPrinterDlg::getOptions( QMap<QString, QString>& opts, bool include_def ) +{ + if ( include_def || !printHeaderTable->isChecked() ) + opts[ "app-kmplot-printtable" ] = ( printHeaderTable->isChecked() ? "1" : "-1" ); + if ( include_def || !transparent_background->isChecked() ) + opts[ "app-kmplot-printbackground" ] = ( transparent_background->isChecked() ? "1" : "-1" ); +} + +void KPrinterDlg::setOptions( const QMap<QString, QString>& opts ) +{ + printHeaderTable->setChecked( opts[ "app-kmplot-printtable" ] != "-1" ); + transparent_background->setChecked( opts[ "app-kmplot-printbackground" ] != "-1" ); +} + +bool KPrinterDlg::isValid( const QString& ) +{ + return true; +} + +#include "kprinterdlg.moc" diff --git a/kmplot/kmplot/kprinterdlg.h b/kmplot/kmplot/kprinterdlg.h new file mode 100644 index 00000000..e875ee7a --- /dev/null +++ b/kmplot/kmplot/kprinterdlg.h @@ -0,0 +1,60 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ +/** @file kprinterdlg.h + * @brief Contains the KPrinterDlg class. */ + +#ifndef kprintdlg_included +#define kprintdlg_included + +// Qt includes +#include <qcheckbox.h> + +// KDE includes +#include <kdeprint/kprintdialogpage.h> + +/** @short A dialog page for the print dialog. + * + * It manages the option to print or not to print the header table with addition plot information. + * It is linked to the app-kmplot-printtable entry in the kmplotrc. + */ +class KPrinterDlg : public KPrintDialogPage +{ + Q_OBJECT +public: + /// Getting the common arguments. + KPrinterDlg( QWidget *parent = 0, const char *name = 0 ); + + /// Reimplemented. + void getOptions( QMap<QString, QString>& opts, bool include_def = false ); + /// Reimplemented. + void setOptions( const QMap<QString, QString>& opts ); + /// Reimplemented. + bool isValid( const QString& msg ); + /// The check box for the option. + QCheckBox *printHeaderTable; + QCheckBox *transparent_background; +}; + +#endif //kprinterdlg_included diff --git a/kmplot/kmplot/ksliderwindow.cpp b/kmplot/kmplot/ksliderwindow.cpp new file mode 100644 index 00000000..675cb9d9 --- /dev/null +++ b/kmplot/kmplot/ksliderwindow.cpp @@ -0,0 +1,121 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2005 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ +// Qt includes +#include <qcursor.h> +#include <qslider.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +// KDE includes +#include <kaction.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kinputdialog.h> +#include <klocale.h> + +#include <limits.h> +#include <math.h> +#include <stdlib.h> + +// local includes +#include "ksliderwindow.h" + +KSliderWindow::KSliderWindow(QWidget* parent, int num ) : + SliderWindow( parent, "", false, Qt::WStyle_Tool-Qt::WStyle_Maximize ), m_num(num) +{ + setCaption(i18n( "Slider %1" ).arg( num+1 ) ); + QToolTip::add( slider, i18n( "Slider no. %1" ).arg( num+1 )); + QWhatsThis::add( this, i18n( "Move slider to change the parameter of the function plot connected to this slider." ) ); + + // load the min and max value + the current value + KConfig config( "kmplotrc" ); + config.setGroup( "slider" + QString::number(num) ); + slider->setMinValue( config.readNumEntry( "min", 0) ); + slider->setMaxValue( config.readNumEntry( "max", 100) ); + slider->setValue( config.readNumEntry( "value", 50) ); + slider->setPageStep( (int)ceil((abs(slider->minValue()) + abs(slider->maxValue()))/10.) ); + + slider->installEventFilter(this); + installEventFilter(this); + + m_popupmenu = new KPopupMenu(this); + KAction *mnuMinValue = new KAction(i18n("&Change Minimum Value") ,0,this, SLOT( mnuMinValue_clicked() ),0); + mnuMinValue->plug(m_popupmenu); + KAction *mnuMaxValue = new KAction(i18n("&Change Maximum Value") ,0,this, SLOT( mnuMaxValue_clicked() ),0 ); + mnuMaxValue->plug(m_popupmenu); +} + +KSliderWindow::~KSliderWindow() +{ + // save the min and max value + the current value + KConfig config( "kmplotrc" ); + config.setGroup( "slider" + QString::number(m_num) ); + config.writeEntry( "min", slider->minValue() ); + config.writeEntry( "max", slider->maxValue() ); + config.writeEntry( "value", slider->value() ); +} + +bool KSliderWindow::eventFilter( QObject *obj, QEvent *ev ) +{ + if (ev->type() == QEvent::MouseButtonPress) + { + QMouseEvent *e = (QMouseEvent *)ev; + if (e->button() != Qt::RightButton) + return SliderWindow::eventFilter( obj, ev ); + m_popupmenu->exec(QCursor::pos()); + return true; + } + return SliderWindow::eventFilter( obj, ev ); +} + +void KSliderWindow::closeEvent( QCloseEvent * e) +{ + emit windowClosed(m_num); + e->accept(); +} + +void KSliderWindow::mnuMinValue_clicked() +{ + bool ok; + int const result = KInputDialog::getInteger(i18n("Change Minimum Value"), i18n("Type a new minimum value for the slider:"), slider->minValue(), INT_MIN, INT_MAX, 1, 10, &ok); + if (!ok) + return; + slider->setMinValue(result); + slider->setPageStep( (int)ceil((abs(slider->maxValue()) + abs(result))/10.) ); + setFocus(); +} + +void KSliderWindow::mnuMaxValue_clicked() +{ + bool ok; + int const result = KInputDialog::getInteger(i18n("Change Maximum Value"), i18n("Type a new maximum value for the slider:"), slider->maxValue(), INT_MIN, INT_MAX, 1, 10, &ok); + if (!ok) + return; + slider->setMaxValue(result); + slider->setPageStep( (int)ceil((abs(slider->minValue()) + abs(result))/10.) ); + setFocus(); +} + +#include "ksliderwindow.moc" diff --git a/kmplot/kmplot/ksliderwindow.h b/kmplot/kmplot/ksliderwindow.h new file mode 100644 index 00000000..115c5010 --- /dev/null +++ b/kmplot/kmplot/ksliderwindow.h @@ -0,0 +1,58 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2005 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef KSLIDERWINDOW_H +#define KSLIDERWINDOW_H + +#include <kpopupmenu.h> + +#include "sliderwindow.h" + +/** @short Slider window for changing a parameter value */ +class KSliderWindow : public SliderWindow +{ + Q_OBJECT + public: + /// @param parent points to the parent widget. + /// @param num number of this instance. + KSliderWindow(QWidget* parent, int num ); + virtual ~KSliderWindow(); + + private slots: + void mnuMinValue_clicked(); + void mnuMaxValue_clicked(); + + signals: + /// emitted when the window has been closed + void windowClosed(int); + + private: + bool eventFilter( QObject *obj, QEvent *ev ); + void closeEvent( QCloseEvent * ); + KPopupMenu *m_popupmenu; + int m_num; +}; + +#endif diff --git a/kmplot/kmplot/main.cpp b/kmplot/kmplot/main.cpp new file mode 100644 index 00000000..594f3a95 --- /dev/null +++ b/kmplot/kmplot/main.cpp @@ -0,0 +1,83 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +/** + * Version string of KmPlot. + */ +#define KP_VERSION "1.2.0" + +// local includes +#include "kmplot.h" + + +// KDE includes +#include <kaboutdata.h> +#include <kapplication.h> +#include <kcmdlineargs.h> + + + +static const char description[] = + I18N_NOOP( "Mathematical function plotter for KDE" ); + +static KCmdLineOptions options[] = + { + { "+[URL]", I18N_NOOP( "File to open" ), 0 }, + KCmdLineLastOption + // INSERT YOUR COMMANDLINE OPTIONS HERE + }; + + +int main( int argc, char **argv ) +{ + KAboutData aboutData( + "kmplot", + I18N_NOOP( "KmPlot" ), + KP_VERSION, description, KAboutData::License_GPL, + "(c) 2000-2002, Klaus-Dieter Möller", + 0, + "http://edu.kde.org/kmplot/" ); + aboutData.addAuthor( + "Klaus-Dieter Möller", I18N_NOOP( "Original Author" ) , + "kdmoeller@foni.net" ); + aboutData.addAuthor( + "Matthias Meßmer", I18N_NOOP( "GUI" ) , + "bmlmessmer@web.de" ); + aboutData.addAuthor( "Fredrik Edemar", I18N_NOOP( "Various improvements" ), "f_edemar@linux.se" ); + aboutData.addCredit( "David Vignoni", I18N_NOOP( "svg icon" ), "david80v@tin.it" ); + aboutData.addCredit( "Albert Astals Cid", I18N_NOOP( "command line options, MIME type" ), "tsdgeos@terra.es" ); + + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + KApplication ka; + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + KmPlot *w = new KmPlot( args ); + w->show(); + ka.setMainWidget( w ); + + return ka.exec(); +} + diff --git a/kmplot/kmplot/parser.cpp b/kmplot/kmplot/parser.cpp new file mode 100644 index 00000000..1f3fa011 --- /dev/null +++ b/kmplot/kmplot/parser.cpp @@ -0,0 +1,1165 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. +* +*/ + +// standard c(++) includes +#include <stdlib.h> +#include <stdio.h> +#include <math.h> + +//KDE includes +#include <kdebug.h> +#include <klocale.h> +#include <kmessagebox.h> + +// local includes +#include "parser.h" +#include "settings.h" +#include "xparser.h" + +double Parser::m_anglemode = 0; + +/// List of predefined functions. +Parser::Mfkt Parser::mfkttab[ FANZ ]= +{ + {"tanh", ltanh}, // Tangens hyperbolicus + {"tan", ltan}, // Tangens + {"sqrt", sqrt}, // Square root + {"sqr", sqr}, // Square + {"sinh", lsinh}, // Sinus hyperbolicus + {"sin", lsin}, // Sinus + {"sign", sign}, // Signum + {"sech", sech}, // Secans hyperbolicus + {"sec", sec}, // Secans + {"log", llog}, // Logarithm base 10 + {"ln", ln}, // Logarithm base e + {"exp", exp}, // Exponential function base e + {"coth", coth}, // Co-Tangens hyperbolicus + {"cot", cot}, // Co-Tangens = 1/tan + {"cosh", lcosh}, // Cosinus hyperbolicus + {"cosech", cosech}, // Co-Secans hyperbolicus + {"cosec", cosec}, // Co-Secans + {"cos", lcos}, // Cosinus + {"artanh", artanh}, // Area-tangens hyperbolicus = inverse of tanh + {"arsinh", arsinh}, // Area-sinus hyperbolicus = inverse of sinh + {"arsech", arsech}, // Area-secans hyperbolicus = invers of sech + {"arctanh", artanh}, // The same as artanh + {"arcsinh", arsinh}, // The same as arsinh + {"arccosh", arcosh}, // The same as arcosh + {"arctan", arctan}, // Arcus tangens = inverse of tan + {"arcsin", arcsin}, // Arcus sinus = inverse of sin + {"arcsec", arcsec}, // Arcus secans = inverse of sec + {"arcoth", arcoth}, // Area-co-tangens hyperbolicus = inverse of coth + {"arcosh", arcosh}, // Area-cosinus hyperbolicus = inverse of cosh + {"arcosech", arcosech}, // Area-co-secans hyperbolicus = inverse of cosech + {"arccot", arccot}, // Arcus co-tangens = inverse of cotan + {"arccosec", arccosec}, // Arcus co-secans = inverse of cosec + {"arccos", arccos}, // Arcus cosinus = inverse of cos + {"abs", fabs} // Absolute value +}; + + + +Ufkt::Ufkt() +{ + id = 0; + mem = 0; + mptr = 0; + k = 0; + oldy = 0; + f_mode = true; + f1_mode = false; + f2_mode = false; + integral_mode = false; + integral_use_precision = false; + linewidth = 0; + f1_linewidth = 0; + f2_linewidth = 0; + integral_linewidth = 0; + double dmin = 0.0; + dmax = 0.0; + oldyprim = 0.0; + oldx = 0.0; + starty = 0.0; + startx = 0.0; + integral_precision = 0.0; + use_slider = -1; + usecustomxmin = false; + usecustomxmax = false; + +} + +Ufkt::~Ufkt() +{ +} + + +Parser::Parser() +{ + ps_init(); +} + + +void Parser::ps_init() +{ + evalflg=0; + Ufkt temp; + temp.fname = temp.fvar = temp.fpar = temp.fstr = ""; + temp.mem=new unsigned char [MEMSIZE]; + ufkt.append(temp ); + current_item = ufkt.begin(); +} + + +Parser::~Parser() +{ + kdDebug() << "Exiting......" << endl; + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + kdDebug() << "Deleting something... :-)" << endl; + delete [](*it).mem; + } +} + +void Parser::setAngleMode(int angle) +{ + if(angle==0) + m_anglemode = 1; + else + m_anglemode = M_PI/180; +} + +void Parser::setDecimalSymbol(const QString c) +{ + m_decimalsymbol = c; +} + +double Parser::anglemode() +{ + return m_anglemode; +} + + +uint Parser::getNewId() +{ + uint i = 0; + bool found = false; + while (1 ) + { + found = false; + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + if (it->id == i && !it->fname.isEmpty()) + { + found = true; + break; + } + } + if (!found) + return i; + ++i; + } +} + +double Parser::eval(QString str) +{ + stack=new double [STACKSIZE]; + stkptr=stack; + evalflg=1; + + fix_expression(str,0); + + if ( str.contains('y')!=0) + { + err=9; + delete []stack; + return 0; + } + for (uint i=0;i<str.length();i++ ) + if (str.at(i).category() == QChar::Letter_Uppercase) + { + err=14; + delete []stack; + return 0; + } + + lptr=str.latin1(); + err=0; + heir1(); + if(*lptr!=0 && err==0) err=1; + evalflg=0; + double const erg=*stkptr; + delete [] stack; + if(err==0) + { + errpos=0; + return erg; + } + else + { + errpos=lptr-(str.latin1())+1; + return 0.; + } +} + +int Parser::idValue(int const ix) +{ + if ( ix >=0 && ix<(int)ufkt.count() ) // range check + { + if ( !( ufkt.count()==1 && ufkt[0].fname.isEmpty() ) ) + return ufkt[ix].id; + } + return -1; + +} + +int Parser::ixValue(uint const id) +{ + int ix=0; + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + if ( it->id ==id) + return ix; + ix++; + } + return -1; +} + +double Parser::fkt(uint const id, double const x) +{ + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + if ( it->id == id) + return fkt(it,x); + } + err=13; + return 0; +} + +double Parser::fkt(Ufkt *it, double const x) +{ + double *pd, (**pf)(double); + double *stack, *stkptr; + uint *puf; + it->mptr=it->mem; + stack=stkptr= new double [STACKSIZE]; + + while(1) + { + switch(*it->mptr++) + { + case KONST: + pd=(double*)it->mptr; + *stkptr=*pd++; + it->mptr=(unsigned char*)pd; + break; + case XWERT: + *stkptr=x; + break; + case YWERT: + *stkptr=it->oldy; + break; + case KWERT: + *stkptr=it->k; + break; + case PUSH: + ++stkptr; + break; + case PLUS: + stkptr[-1]+=*stkptr; + --stkptr; + break; + case MINUS: + stkptr[-1]-=*stkptr; + --stkptr; + break; + case MULT: + stkptr[-1]*=*stkptr; + --stkptr; + break; + case DIV: + if(*stkptr==0.)*(--stkptr)=HUGE_VAL; + else + { + stkptr[-1]/=*stkptr; + --stkptr; + } + break; + case POW: + stkptr[-1]=pow(*(stkptr-1), *stkptr); + --stkptr; + break; + case NEG: + *stkptr=-*stkptr; + break; + case FKT: + pf=(double(**)(double))it->mptr; + *stkptr=(*pf++)(*stkptr); + it->mptr=(unsigned char*)pf; + break; + case UFKT: + { + puf=(uint*)it->mptr; + uint id = *puf++; + for( QValueVector<Ufkt>::iterator ite = ufkt.begin(); ite != ufkt.end(); ++ite) + { + if ( ite->id == id) + { + *stkptr=fkt(ite, *stkptr); + break; + } + } + it->mptr=(unsigned char*)puf; + break; + } + case ENDE: + double const erg=*stkptr; + delete [] stack; + return erg; + } + } +} + +int Parser::addfkt(QString str) +{ + QString const extstr = str; + stkptr=stack=0; + err=0; + errpos=1; + const int p1=str.find('('); + int p2=str.find(','); + const int p3=str.find(")="); + fix_expression(str,p1+4); + + if(p1==-1 || p3==-1 || p1>p3) + { err=4; + return -1; + } + if ( p3+2 == (int) str.length()) //empty function + { err=11; + return -1; + } + if(p2==-1 || p2>p3) p2=p3; + + if( fnameToId(str.left(p1))!=-1 ) + { + err=8; + return -1; + } + else + err=0; + + if (str.mid(p1+1, p2-p1-1) == "e") + { err=4; + return -1; + } + + if ( ufkt.begin()->fname.isEmpty() ) + { + ufkt.begin()->id = 0; + //kdDebug() << "ufkt.begin()->id:" << ufkt.begin()->id << endl; + } + else + { + Ufkt temp; + if ( !temp.fstr.isEmpty() && temp.fstr.at(0) == 'y') + temp.id = ufkt.last().id; //the function belongs to the last inserted function + else + temp.id = getNewId(); + temp.mem=new unsigned char [MEMSIZE]; + ufkt.append(temp ); + } + QString const fname = str.left(p1); + Ufkt *temp = &ufkt.last(); + temp->fstr=extstr; + temp->mptr = 0; + temp->fname=fname; + temp->fvar=str.mid(p1+1, p2-p1-1); + if(p2<p3) temp->fpar=str.mid(p2+1, p3-p2-1); + else temp->fpar=""; //.resize(1); + + kdDebug() << "temp.id:" << temp->id << endl; + + if ( temp->fname != temp->fname.lower() ) //isn't allowed to contain capital letters + { + delfkt(temp); + err=12; + return -1; + } + current_item = temp; + mem=mptr=temp->mem; + lptr=(str.latin1())+p3+2; + heir1(); + if(*lptr!=0 && err==0) err=1; // Syntaxfehler + addtoken(ENDE); + if(err!=0) + { + errpos=lptr-(str.latin1())+1; + delfkt(temp); + return -1; + } + errpos=0; + return temp->id; //return the unique ID-number for the function +} + +void Parser::reparse(int ix) +{ + reparse( &ufkt[ix] ); +} + +void Parser::reparse(Ufkt *item) +{ + kdDebug() << "Reparsing: " << item->fstr << endl; + QString str = item->fstr.latin1(); + err=0; + errpos=1; + + const int p1=str.find('('); + int p2=str.find(','); + const int p3=str.find(")="); + + fix_expression(str,p1+4); + + if(p1==-1 || p3==-1 || p1>p3) + { err=4; + return; + } + if ( p3+2 == (int) str.length()) //empty function + { err=11; + return; + } + if(p2==-1 || p2>p3) p2=p3; + + if (str.mid(p1+1, p2-p1-1) == "e") + { err=4; + return; + } + + item->fname=str.left(p1); + item->fvar=str.mid(p1+1, p2-p1-1); + if(p2<p3) item->fpar=str.mid(p2+1, p3-p2-1); + else item->fpar=""; + + if ( item->fname != item->fname.lower() ) //isn't allowed to contain capital letters + { + err=12; + return; + } + + //ixa=ix; + current_item = item; + mem=mptr=item->mem; + lptr=(str.latin1())+p3+2; + heir1(); + if(*lptr!=0 && err==0) err=1; // Syntaxfehler + addtoken(ENDE); + errpos=0; +} + +void Parser::fix_expression(QString &str, int const pos) +{ + str.remove(" " ); + + //insert '*' when it is needed + QChar ch; + bool function = false; + for(uint i=pos; i < str.length();i++) + { + ch = str.at(i); + if ( str.at(i+1)=='(' && ch.category()==QChar::Letter_Lowercase ) + { + QString str_function(ch); + int n=i-1; + while (n>0 && str.at(n).category() == QChar::Letter_Lowercase ) + { + str_function.prepend(str.at(n)); + --n; + } + if (str_function == "tanh" || str_function == "tan" || str_function =="sqrt" || str_function =="sqr" || str_function =="sin" || str_function =="sinh" || str_function =="sign" || str_function =="sech" || str_function =="sec" || str_function =="log" || str_function =="ln" || str_function =="exp" || str_function =="coth" || str_function =="cot" || str_function =="cosh" || str_function =="cosech" || str_function =="cosec" || str_function =="cos" || str_function =="artanh" || str_function =="arsinh" || str_function =="arsech" || str_function =="arctan" || str_function =="arcsin" || str_function =="arcsec" || str_function =="arcoth" || str_function =="arcosh" || str_function =="arcosech" || str_function =="arccot" || str_function =="arccosec" || str_function =="arccos" || str_function =="abs" || str_function=="arctanh" || str_function=="arcsinh" || str_function=="arccosh") + function = true; + else + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + for ( int j=i; j>0 && (str.at(j).isLetter() || str.at(j).isNumber() ) ; --j) + { + if ( it->fname == str.mid(j,i-j+1) ) + function = true; + } + } + } + else if (function) + function = false; + + if( (ch.isNumber() || ch.category()==QChar::Letter_Uppercase )&& ( str.at(i-1).isLetter() || str.at(i-1) == ')' ) || (ch.isLetter() && str.at(i-1)==')') ) + str.insert(i,'*'); + else if( (ch.isNumber() || ch == ')' || ch.category()==QChar::Letter_Uppercase) && ( str.at(i+1).isLetter() || str.at(i+1) == '(' ) || (ch.isLetter() && str.at(i+1)=='(' && !function ) ) + { + str.insert(i+1,'*'); + i++; + } + } + QString str_end = str.mid(pos); + str_end = str_end.replace(m_decimalsymbol, "."); //replace the locale decimal symbol with a '.' + str.truncate(pos); + str.append(str_end); + //kdDebug() << "str:" << str << endl; +} + +bool Parser::delfkt( Ufkt *item) +{ + kdDebug() << "Deleting id:" << item->id << endl; + if (!item->dep.isEmpty()) + { + KMessageBox::error(0,i18n("This function is depending on an other function")); + return false; + } + for(QValueVector<Ufkt>::iterator it1=ufkt.begin(); it1!=ufkt.end(); ++it1) + { + if (it1==item) + continue; + for(QValueList<int>::iterator it2=it1->dep.begin(); it2!=it1->dep.end(); ++it2) + if ( (uint)*it2 == item->id ) + it2 = it1->dep.erase(it2); + } + + if ( ufkt.count()==1 ) + { + //kdDebug() << "first item, don't delete" << endl; + item->fname=""; + } + else + { + //kdDebug() << "Deleting something" << endl; + QChar const extstr_c = item->fstr.at(0); + uint const id = item->id; + delete []item->mem; + ufkt.erase(item); + if ( extstr_c == 'x') + { + int const ix = ixValue(id+1); + if (ix!= -1 && ufkt[ix].fstr.at(0) == 'y') + delfkt( &ufkt[ix]); + } + else if ( extstr_c == 'y') + { + int const ix = ixValue(id-1); + if (ix!= -1 && ufkt[ix].fstr.at(0) == 'x') + delfkt( &ufkt[ix]); + } + } + return true; +} + +bool Parser::delfkt(uint id) +{ + int ix = ixValue(id); + if ( ix!=-1 && delfkt(&ufkt[ix])) + return true; + else + return false; +} + +uint Parser::countFunctions() +{ + uint const count = ufkt.count(); + if (count == 1 && ufkt.begin()->fname.isEmpty()) + return 0; + else + return count; +} + +void Parser::heir1() +{ + char c; + heir2(); + if(err!=0) return ; + + while(1) + { + switch(c=*lptr) + { + default: + return ; + + case ' ': + ++lptr; + continue; + case '+': + case '-': + ++lptr; + addtoken(PUSH); + heir2(); + if(err!=0) + return; + } + switch(c) + { + case '+': + addtoken(PLUS); + break; + case '-': + addtoken(MINUS); + } + } +} + + +void Parser::heir2() +{ + if(match("-")) + { + heir2(); + if(err!=0) + return; + addtoken(NEG); + } + else + heir3(); +} + + +void Parser::heir3() +{ + char c; + heir4(); + if(err!=0) + return; + while(1) + { + switch(c=*lptr) + { + default: + return; + case ' ': + ++lptr; + continue; + case '*': + case '/': + ++lptr; + addtoken(PUSH); + heir4(); + if(err!=0) + return ; + } + switch(c) + { + case '*': + addtoken(MULT); + break; + case '/': + addtoken(DIV); + } + } +} + + +void Parser::heir4() +{ + primary(); + if(err!=0) + return; + while(match("^")) + { + addtoken(PUSH); + primary(); + if(err!=0) + return; + addtoken(POW); + } +} + + +void Parser::primary() +{ + if(match("(")) + { + heir1(); + if(match(")")==0) + err=2; // fehlende Klammer + return; + } + int i; + for(i=0; i<FANZ; ++i) + { + if(match(mfkttab[i].mfstr)) + { + primary(); + addtoken(FKT); + addfptr(mfkttab[i].mfadr); + return; + } + } + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + if(QString(lptr)=="pi" || QString(lptr)=="e") continue; + + if( match(it->fname.latin1()) ) + { + if (it == current_item) + { + err=9; + return; + } + primary(); + addtoken(UFKT); + addfptr( it->id ); + it->dep.append(current_item->id); + return; + } + } + + // A constant + if(lptr[0] >='A' && lptr[0]<='Z' ) + { + char tmp[2]; + tmp[1] = '\0'; + for( i = 0; i< (int)constant.size();i++) + { + tmp[0] = constant[i].constant; + if ( match( tmp) ) + { + addtoken(KONST); + addwert(constant[i].value); + return; + } + } + err = 10; + return; + } + + if(match("pi")) + { + addtoken(KONST); + addwert(M_PI); + return; + } + + if(match("e")) + { + addtoken(KONST); + addwert(M_E); + return; + } + //if(match(ufkt[ixa].fvar.latin1())) + if(match(current_item->fvar.latin1())) + { + addtoken(XWERT); + return; + } + + if(match("y")) + { + addtoken(YWERT); + return; + } + + //if(match(ufkt[ixa].fpar.latin1())) + if(match(current_item->fpar.latin1())) + { + addtoken(KWERT); + return; + } + + char *p; + double const w=strtod(lptr, &p); + if(lptr!=p) + { + lptr=p; + addtoken(KONST); + addwert(w); + } + else + err=1; // Syntax-Fehler +} + + +int Parser::match(const char *lit) +{ + + const char *p; + if(*lit==0) + return 0; + while(*lptr==' ') + ++lptr; + p=lptr; + + while(*lit) + { + if(*lit++!=*p++) + return 0; + } + lptr=p; + return 1; +} + + +void Parser::addtoken(unsigned char token) +{ + if(stkptr>=stack+STACKSIZE-1) + { + err=7; + return; + } + + if(evalflg==0) + { + if(mptr>=&mem[MEMSIZE-10]) + err=6; + else + *mptr++=token; + + switch(token) + { + case PUSH: + ++stkptr; + break; + case PLUS: + case MINUS: + case MULT: + case DIV: + case POW: + --stkptr; + } + } + else switch(token) + { + case PUSH: + ++stkptr; + break; + case PLUS: + stkptr[-1]+=*stkptr; + --stkptr; + break; + + case MINUS: + stkptr[-1]-=*stkptr; + --stkptr; + break; + case MULT: + stkptr[-1]*=*stkptr; + --stkptr; + break; + case DIV: + if(*stkptr==0.) + *(--stkptr)=HUGE_VAL; + else + { + stkptr[-1]/=*stkptr; + --stkptr; + } + break; + + case POW: + stkptr[-1]=pow(*(stkptr-1), *stkptr); + --stkptr; + break; + case NEG: + *stkptr=-*stkptr; + } +} + + +void Parser::addwert(double x) +{ + double *pd=(double*)mptr; + + if(evalflg==0) + { + if(mptr>=&mem[MEMSIZE-10]) + err=6; + else + { + *pd++=x; + mptr=(unsigned char*)pd; + } + } + else + *stkptr=x; +} + + +void Parser::addfptr(double(*fadr)(double)) +{ + double (**pf)(double)=(double(**)(double))mptr; + if( evalflg==0 ) + { + if( mptr>=&mem[MEMSIZE-10] ) + err=6; + else + { + *pf++=fadr; + mptr=(unsigned char*)pf; + } + } + else + *stkptr=(*fadr)(*stkptr); +} + + +void Parser::addfptr(uint id) +{ + uint *p=(uint*)mptr; + if(evalflg==0) + { + if(mptr>=&mem[MEMSIZE-10]) err=6; + else + { + *p++=id; + mptr=(unsigned char*)p; + } + } + else + { + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + if ( it->id == id) + { + *stkptr=fkt(it, *stkptr); + break; + } + } +} + + +int Parser::fnameToId(const QString &name) +{ + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + if(name==it->fname) + return it->id; + } + return -1; // Name nicht bekannt +} + + +int Parser::parserError(bool showMessageBox) +{ + if (!showMessageBox) + return err; + switch(err) + { + case 1: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Syntax error").arg(QString::number(errpos)), "KmPlot"); + break; + case 2: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Missing parenthesis").arg(QString::number(errpos)), "KmPlot"); + break; + case 3: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Function name unknown").arg(QString::number(errpos)), "KmPlot"); + break; + case 4: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Void function variable").arg(QString::number(errpos)), "KmPlot"); + break; + case 5: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Too many functions").arg(QString::number(errpos)), "KmPlot"); + break; + case 6: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Token-memory overflow").arg(QString::number(errpos)), "KmPlot"); + break; + case 7: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Stack overflow").arg(QString::number(errpos)), "KmPlot"); + break; + case 8: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "Name of function not free.").arg(QString::number(errpos)), "KmPlot"); + break; + case 9: KMessageBox::error(0, i18n("Parser error at position %1:\n" + "recursive function not allowed.").arg(QString::number(errpos)), "KmPlot"); + break; + case 10: KMessageBox::error(0, i18n("Could not find a defined constant at position %1." ).arg(QString::number(errpos)), + "KmPlot"); + break; + case 11: KMessageBox::error(0, i18n("Empty function"), "KmPlot"); + break; + case 12: KMessageBox::error(0, i18n("The function name is not allowed to contain capital letters."), "KmPlot"); + break; + case 13: KMessageBox::error(0, i18n("Function could not be found."), "KmPlot"); + break; + case 14: KMessageBox::error(0, i18n("The expression must not contain user-defined constants."), "KmPlot"); + break; + } + return err; +} + + + +// static +QString Parser::number( double value ) +{ + QString str = QString::number( value, 'g', 6 ); + str.replace( 'e', "*10^" ); +// kDebug() << "returning str="<<str<<endl; + return str; +} + + + +double ln(double x) +{ + return log(x); +} + +double llog(double x) +{ + return log10(x); +} + +double sign(double x) +{ + if(x<0.) + return -1.; + else + if(x>0.) + return 1.; + return 0.; +} + +double sqr(double x) +{ + return x*x; +} + +double arsinh(double x) +{ + return log(x+sqrt(x*x+1)); +} + + +double arcosh(double x) +{ + return log(x+sqrt(x*x-1)); +} + + +double artanh(double x) +{ + return log((1+x)/(1-x))/2; +} + +// sec, cosec, cot and their inverses + +double sec(double x) +{ + return (1 / cos(x*Parser::anglemode())); +} + +double cosec(double x) +{ + return (1 / sin(x*Parser::anglemode())); +} + +double cot(double x) +{ + return (1 / tan(x*Parser::anglemode())); +} + +double arcsec(double x) +{ + if ( !Parser::anglemode() ) + return ( 1/acos(x)* 180/M_PI ); + else + return acos(1/x); +} + +double arccosec(double x) +{ + return asin(1/x)* 1/Parser::anglemode(); +} + +double arccot(double x) +{ + return atan(1/x)* 1/Parser::anglemode(); +} + +// sech, cosech, coth and their inverses + + +double sech(double x) +{ + return (1 / cosh(x*Parser::anglemode())); +} + +double cosech(double x) +{ + return (1 / sinh(x*Parser::anglemode())); +} + +double coth(double x) +{ + return (1 / tanh(x*Parser::anglemode())); +} + +double arsech(double x) +{ + return arcosh(1/x)* 1/Parser::anglemode(); +} + +double arcosech(double x) +{ + return arsinh(1/x)* 1/Parser::anglemode(); +} + +double arcoth(double x) +{ return artanh(1/x)* 1/Parser::anglemode(); +} + +//basic trigonometry functions + +double lcos(double x) +{ + return cos(x*Parser::anglemode()); +} +double lsin(double x) +{ + return sin(x*Parser::anglemode()); +} +double ltan(double x) +{ + return tan(x*Parser::anglemode()); +} + +double lcosh(double x) +{ + return cosh(x*Parser::anglemode()); +} +double lsinh(double x) +{ + return sinh(x*Parser::anglemode()); +} +double ltanh(double x) +{ + return tanh(x*Parser::anglemode()); +} + +double arccos(double x) +{ + return acos(x) * 1/Parser::anglemode(); +} +double arcsin(double x) +{ + return asin(x)* 1/Parser::anglemode(); +} + +double arctan(double x) +{ + return atan(x)* 1/Parser::anglemode(); +} diff --git a/kmplot/kmplot/parser.h b/kmplot/kmplot/parser.h new file mode 100644 index 00000000..82111080 --- /dev/null +++ b/kmplot/kmplot/parser.h @@ -0,0 +1,285 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter M�ler +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. +* +*/ + +/** @file parser.h + * \brief Contains the parser core class Parser. */ + +// Qt includes +#include <qstring.h> +#include <qvaluevector.h> + +#include "parseriface.h" + +#ifndef parser_included +#define parser_included + +// Voreinstellungen bei Verwendung des Standardkonstruktors : + +#define MEMSIZE 500 ///< memory size for tokens +#define STACKSIZE 50 ///< stack depth + +//@{ +/** Token type. */ +#define KONST 0 // double value follows +#define XWERT 1 // get x value +#define KWERT 2 // get function parameter +#define PUSH 3 // push value to stack +#define PLUS 4 // add +#define MINUS 5 // subtract +#define MULT 6 // multiply +#define DIV 7 // divide +#define POW 8 // exponentiate +#define NEG 9 // negate +#define FKT 10 // address to function followes +#define UFKT 11 // address to user defined function follows +#define ENDE 12 // end of function +#define YWERT 13 // get y value +#define FANZ 34 // number of mathematical functions in mfkttab[] +//@} + +//@{ +/** Predefined mathematical function. */ +double ln(double x); +double llog(double x); +double sign(double x); +double sqr(double x); +double arsinh(double x); +double arcosh(double x); +double artanh(double x); + +double sec(double x); +double cosec(double x); +double cot(double x); +double arcsec(double x); +double arccosec(double x); +double arccot(double x); + +double sech(double x); +double cosech(double x); +double coth(double x); +double arsech(double x); +double arcosech(double x); +double arcoth(double x); + +double lcos(double x); +double lsin(double x); +double ltan(double x); + +double lcosh(double x); +double lsinh(double x); +double ltanh(double x); + +double arccos(double x); +double arcsin(double x); +double arctan(double x); + +/// A parameter expression and value +class ParameterValueItem +{ + public: + ParameterValueItem(const QString &e, double v) + { + expression = e; + value = v; + } + ParameterValueItem() {;} + QString expression; + double value; +}; + + +/** Here are all atitrbutes for a function stored. */ +class Ufkt +{ + public: + Ufkt(); + ~Ufkt(); + /// Sets the parameter + void setParameter(double const &p) {k = p; } + + uint id; + unsigned char *mem; ///< Pointer to the allocated memory for the tokens. + unsigned char *mptr; ///< Pointer to the token. + QString fname; ///< Name of the function. + QString fvar; ///< Dummy variable. + QString fpar; ///< Parameter. + QString fstr; ///< Function expression. + double k, ///< Function parameter. + oldy; ///< The last y-value needed for Euler's method + QValueList<int> dep; /// A list with all functions this function depends on + + bool f_mode, ///< \a f_mode == 1: draw the plot. + f1_mode, ///< \a f1_mode == 1. draw the 1st derivative, too. + f2_mode,///< \a f2_mode == 1. draw the 2nd derivative, too. + integral_mode, ///< \a f2_mode == 1. draw the integral, too. + integral_use_precision; ///< The user can specify an unic precision for numeric prime-functions + int linewidth,f1_linewidth,f2_linewidth, integral_linewidth; ///< Line width. + /** Number of parameter values. + * @see FktExt::k_liste */ + QString str_dmin, str_dmax, str_startx, str_starty ; /// Plot range, input strings. + double dmin, ///< Custom plot range, lower boundage. + dmax, ///< Custom plot range, upper boundage. + /** List of parameter values. + * @see FktExt::k_anz */ + oldyprim, ///< needed for Euler's method, the last y'.value + oldx, ///< needed for Euler's method, the last x-value + starty,///< startposition for Euler's method, the initial y-value + startx, ///< startposition for Euler's method, the initial x-value last y'.valuenitial x-value last y'.valuenitial x-value + integral_precision; ///<precision when drawing numeric prime-functions + QRgb color, ///< current color. + f1_color, f2_color, integral_color; + int use_slider; ///< -1: none (use list), else: slider number + QValueList<ParameterValueItem> parameters; ///< List with parameter for the function + bool usecustomxmin, usecustomxmax; + // TODO double slider_min, slider_max; ///< extreme values of the slider +}; + +class Constant +{ +public: + Constant( char c='A', double v=0) + { + constant = c; + value = v; + } + + char constant; + double value; +}; + +/** @short Parser. + * + * Tokenizes a function equation to be evaluated. + */ +class Parser : virtual public ParserIface +{ +public: + Parser(); + ~Parser(); + + /** + * @return A string that is safe to use as a number in a string to be + * parsed. This is needed as e.g. "1.2e-3" is not allowed (e is a + * constant) - so cannot use the QString::number. + */ + static QString number( double value ); + + /// Returns the result of a calculation + double fkt(Ufkt *it, double const x); + double fkt(uint id, double const x); + + /// Evaluates the given expression. + double eval(QString); + /// Adds a user defined function with the given equation. The new function's ID-number is returned. + int addfkt(QString); + /// Removes the function with the given id. + bool delfkt(uint id); + bool delfkt( Ufkt *item); + + /// Returns the ID-number of the function "name". If the function couldn't be found, -1 is returned. + int fnameToId(const QString &name); + /// Returns the current error value. If showMessageBox is true, an error message box will appear if an error was found + int parserError(bool showMessageBox=TRUE); + + /// return the angletype + static double anglemode(); + /// Sets the angletype. TRUE is radians and FALSE degrees + void setAngleMode(int); + /// sets the decimal symbol + void setDecimalSymbol(const QString ); + + /// reparse the function. It also do a grammer check for the expression + void reparse(int ix); + void reparse(Ufkt *item); + + uint getNewId(); /// Returns the next ID-number + int idValue(int const ix); /// Converts an index-value to an ID-number + int ixValue(uint const id);/// Converts an ID-numer to an index-value + uint countFunctions(); /// Returns how many functions there are + + QValueVector<Constant> constant; + QValueVector<Ufkt> ufkt;///< Points to the array of user defined functions. + +private: + /** Mathematical function. */ + struct Mfkt + { + const char *mfstr; + double (*mfadr)(double); + }; + static Mfkt mfkttab[FANZ]; + + /// Error codes: + /** + * The values have following meanings: + * \li 0 => parse success + * \li 1 => syntax error + * \li 2 => missing bracket + * \li 3 => function unknown + * \li 4 => function variable not valid + * \li 5 => too much functions + * \li 6 => memory overflow + * \li 7 => stack overflow + * \li 8 => function name already used + * \li 9 => recursive function call + * \li 10 => didn't found the wanted constant + * \li 11 => emtpy function + * \li 12 => function name contains a capital letter + * \li 13 => function could not be found + * \li 14 => evalation expression may not use user definded constants + */ + int err; + /// Position where the error occurred. + int errpos; + + void fix_expression(QString &, int const); ///adding extra *-characters, remove spaces and replace the locale .-character with '.' + + void ps_init(), + heir1(), + heir2(), + heir3(), + heir4(), + primary(), + addtoken(unsigned char), + addwert(double), + addfptr(double(*)(double)), + addfptr(uint ); + int match(const char*); + + unsigned + char evalflg, // 0 => String wird tokenisiert + // 1 => String wird direkt ausgewertet + *mem, // Zeiger auf Speicher fr Token + *mptr; // Zeiger fr Token + const + char *lptr; // Zeiger fr Funktions-String + Ufkt *current_item; // Pointer to the current function + double *stack, // Zeiger auf Stackanfang + *stkptr; // Stackpointer + static double m_anglemode; + QString m_decimalsymbol; +}; + +#endif // parser_included diff --git a/kmplot/kmplot/parseriface.h b/kmplot/kmplot/parseriface.h new file mode 100644 index 00000000..07020ebb --- /dev/null +++ b/kmplot/kmplot/parseriface.h @@ -0,0 +1,89 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 2004 Fredrik Edemar +* f_edemar@linux.se +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef XPARSERIFACE_H +#define XPARSERIFACE_H + +#include <dcopobject.h> +#include <qcolor.h> +#include <qstringlist.h> + +/** +@author Fredrik Edemar +*/ +/// All functions in ParserIface are accessible with DCOP. For descriptions about the functions, see Parser and XParser. +class ParserIface : virtual public DCOPObject +{ + K_DCOP +k_dcop: + virtual bool addFunction(const QString &extstr, bool f_mode, bool f1_mode, bool f2_mode, bool integral_mode, bool integral_use_precision, int linewidth, int f1_linewidth, int f2_linewidth, int integral_linewidth, const QString &str_dmin, const QString &str_dmax, const QString &str_startx, const QString &str_starty, double integral_precision, QRgb color, QRgb f1_color, QRgb f2_color, QRgb integral_color, QStringList str_parameter, int use_slider) = 0; + + virtual int addFunction(const QString &f_str) = 0; + virtual bool delfkt(uint id) = 0; + virtual bool setFunctionExpression(const QString &f_str, uint id) = 0; + virtual uint countFunctions() = 0; + virtual QStringList listFunctionNames() = 0; + virtual int fnameToId(const QString &name) = 0; + virtual double fkt(uint id, double x) = 0; + virtual bool functionFVisible(uint id) = 0; + virtual bool functionF1Visible(uint id) = 0; + virtual bool functionF2Visible(uint id) = 0; + virtual bool functionIntVisible(uint id) = 0; + virtual bool setFunctionFVisible(bool visible, uint id) = 0; + virtual bool setFunctionF1Visible(bool visible, uint id) = 0; + virtual bool setFunctionF2Visible(bool visible, uint id) = 0; + virtual bool setFunctionIntVisible(bool visible, uint id) = 0; + virtual QString functionStr(uint id) = 0; + virtual QColor functionFColor(uint id) = 0; + virtual QColor functionF1Color(uint id) = 0; + virtual QColor functionF2Color(uint id) = 0; + virtual QColor functionIntColor(uint id) = 0; + virtual bool setFunctionFColor(const QColor &color, uint id) = 0; + virtual bool setFunctionF1Color(const QColor &color, uint id) = 0; + virtual bool setFunctionF2Color(const QColor &color, uint id) = 0; + virtual bool setFunctionIntColor(const QColor &color, uint id) = 0; + virtual int functionFLineWidth(uint id) = 0; + virtual int functionF1LineWidth(uint id) = 0; + virtual int functionF2LineWidth(uint id) = 0; + virtual int functionIntLineWidth(uint id) = 0; + virtual bool setFunctionFLineWidth(int linewidth, uint id) = 0; + virtual bool setFunctionF1LineWidth(int linewidth, uint id) = 0; + virtual bool setFunctionF2LineWidth(int linewidth, uint id) = 0; + virtual bool setFunctionIntLineWidth(int linewidth, uint id) = 0; + virtual QStringList functionParameterList(uint id) = 0; + virtual bool functionAddParameter(const QString &new_parameter, uint id) = 0; + virtual bool functionRemoveParameter(const QString &remove_parameter, uint id) = 0; + virtual QString functionMinValue(uint id) = 0; + virtual QString functionMaxValue(uint id) = 0; + virtual bool setFunctionMinValue(const QString &min, uint id) = 0; + virtual bool setFunctionMaxValue(const QString &max, uint id) = 0; + virtual QString functionStartXValue(uint id) = 0; + virtual QString functionStartYValue(uint id) = 0; + virtual bool setFunctionStartXValue(const QString &x, uint id) = 0; + virtual bool setFunctionStartYValue(const QString &y, uint id) = 0; + +}; + +#endif diff --git a/kmplot/kmplot/qconstanteditor.ui b/kmplot/kmplot/qconstanteditor.ui new file mode 100644 index 00000000..92baf7e5 --- /dev/null +++ b/kmplot/kmplot/qconstanteditor.ui @@ -0,0 +1,200 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>QConstantEditor</class> +<widget class="QWidget"> + <property name="name"> + <cstring>QConstantEditor</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>388</width> + <height>341</height> + </rect> + </property> + <property name="caption"> + <string>Constant Editor</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="2" column="1"> + <property name="name"> + <cstring>cmdDelete</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Delete</string> + </property> + <property name="toolTip" stdset="0"> + <string>delete selected constant</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to delete the selected constant; it can only be removed if it is not currently used by a plot.</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>cmdEdit</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Change Value...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Change the value of a user-defined constant</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to edit the value of the selected constant. Its name cannot be changed.</string> + </property> + </widget> + <widget class="QPushButton" row="3" column="1"> + <property name="name"> + <cstring>cmdDuplicate</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>D&uplicate</string> + </property> + <property name="toolTip" stdset="0"> + <string>Duplicate the selected constant</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to Copy the selected constant to another constant. You can choose the new name from a list.</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="1"> + <property name="name"> + <cstring>cmdNew</cstring> + </property> + <property name="text"> + <string>&New...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Add a new constant</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to add a new constant.</string> + </property> + </widget> + <widget class="KListView" row="0" column="0" rowspan="5" colspan="1"> + <column> + <property name="text"> + <string>Variable</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Value</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>varlist</cstring> + </property> + <property name="showSortIndicator"> + <bool>true</bool> + </property> + <property name="itemsMovable"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>List of user-defined constants</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select a constant to change its value, remove it or duplicate it.</string> + </property> + </widget> + <spacer row="4" column="1"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>147</height> + </size> + </property> + </spacer> + </grid> +</widget> +<connections> + <connection> + <sender>cmdNew</sender> + <signal>clicked()</signal> + <receiver>QConstantEditor</receiver> + <slot>cmdNew_clicked()</slot> + </connection> + <connection> + <sender>cmdEdit</sender> + <signal>clicked()</signal> + <receiver>QConstantEditor</receiver> + <slot>cmdEdit_clicked()</slot> + </connection> + <connection> + <sender>cmdDelete</sender> + <signal>clicked()</signal> + <receiver>QConstantEditor</receiver> + <slot>cmdDelete_clicked()</slot> + </connection> + <connection> + <sender>varlist</sender> + <signal>clicked(QListViewItem*)</signal> + <receiver>QConstantEditor</receiver> + <slot>varlist_clicked(QListViewItem*)</slot> + </connection> + <connection> + <sender>cmdDuplicate</sender> + <signal>clicked()</signal> + <receiver>QConstantEditor</receiver> + <slot>cmdDuplicate_clicked()</slot> + </connection> + <connection> + <sender>varlist</sender> + <signal>doubleClicked(QListViewItem*)</signal> + <receiver>QConstantEditor</receiver> + <slot>varlist_doubleClicked(QListViewItem*)</slot> + </connection> +</connections> +<includes> + <include location="local" impldecl="in implementation">qconstanteditor.ui.h</include> +</includes> +<slots> + <slot>cmdCancel_clicked()</slot> + <slot>cmdNew_clicked()</slot> + <slot>cmdEdit_clicked()</slot> + <slot>cmdDelete_clicked()</slot> + <slot>varlist_clicked( QListViewItem * item )</slot> + <slot>cmdDuplicate_clicked()</slot> + <slot>newNewConstantSlot()</slot> + <slot>varlist_doubleClicked( QListViewItem * )</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistview.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/qconstanteditor.ui.h b/kmplot/kmplot/qconstanteditor.ui.h new file mode 100644 index 00000000..3c174b76 --- /dev/null +++ b/kmplot/kmplot/qconstanteditor.ui.h @@ -0,0 +1,44 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions or slots use +** Qt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ +void QConstantEditor::cmdCancel_clicked() +{ +} + +void QConstantEditor::cmdNew_clicked() +{ +} + +void QConstantEditor::cmdEdit_clicked() +{ +} + +void QConstantEditor::cmdDelete_clicked() +{ +} + + +void QConstantEditor::varlist_clicked( QListViewItem * ) +{ +} + + +void QConstantEditor::cmdDuplicate_clicked() +{ +} + + +void QConstantEditor::newNewConstantSlot() +{ +} + + +void QConstantEditor::varlist_doubleClicked( QListViewItem * ) +{ + +} diff --git a/kmplot/kmplot/qeditconstant.ui b/kmplot/kmplot/qeditconstant.ui new file mode 100644 index 00000000..1d9bdb0a --- /dev/null +++ b/kmplot/kmplot/qeditconstant.ui @@ -0,0 +1,139 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>QEditConstant</class> +<widget class="QDialog"> + <property name="name"> + <cstring>QEditConstant</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>252</width> + <height>115</height> + </rect> + </property> + <property name="caption"> + <string>Edit Constant</string> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Variable:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Value:</string> + </property> + </widget> + <widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>cmdOK</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>71</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>cmdCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + </widget> + </hbox> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>txtConstant</cstring> + </property> + <property name="maxLength"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Name of the constant (only 1 character but "E")</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the name of the constant here. User-defined constant names only have 1 character; the constant "E" (Euler number) is reserved.</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>txtValue</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>Enter the constant's value here.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The value of a constant can be an expression, for instance PI/2 or sqrt(2).</string> + </property> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>txtConstant</sender> + <signal>lostFocus()</signal> + <receiver>QEditConstant</receiver> + <slot>txtVariable_lostFocus()</slot> + </connection> +</connections> +<tabstops> + <tabstop>txtConstant</tabstop> + <tabstop>txtValue</tabstop> + <tabstop>cmdCancel</tabstop> + <tabstop>cmdOK</tabstop> +</tabstops> +<includes> + <include location="local" impldecl="in implementation">qeditconstant.ui.h</include> +</includes> +<slots> + <slot>txtVariable_lostFocus()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/qeditconstant.ui.h b/kmplot/kmplot/qeditconstant.ui.h new file mode 100644 index 00000000..a4b8efba --- /dev/null +++ b/kmplot/kmplot/qeditconstant.ui.h @@ -0,0 +1,13 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions or slots use +** Qt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ + + +void QEditConstant::txtVariable_lostFocus() +{ +} diff --git a/kmplot/kmplot/qeditparametric.ui b/kmplot/kmplot/qeditparametric.ui new file mode 100644 index 00000000..b41573ab --- /dev/null +++ b/kmplot/kmplot/qeditparametric.ui @@ -0,0 +1,545 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>QEditParametric</class> +<widget class="QDialog"> + <property name="name"> + <cstring>QEditParametric</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>335</width> + <height>470</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="caption"> + <string>Edit Parametric Plot</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="title"> + <string>Definition</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>Name:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + <property name="buddy" stdset="0"> + <cstring>kLineEditName</cstring> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>kLineEditXFunction</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip" stdset="0"> + <string>enter an expression</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter an expression for the function. +The dummy variable is t. +Example: cos(t)</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>kLineEditName</cstring> + </property> + <property name="text"> + <string>f</string> + </property> + <property name="toolTip" stdset="0"> + <string>name of the function</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the name of the function. +The name of a function must be unique. If you leave this line empty KmPlot will set a default name. You can change it later.</string> + </property> + </widget> + <widget class="QLayoutWidget" row="2" column="0"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabelY</cstring> + </property> + <property name="text"> + <string>y</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabelYF</cstring> + </property> + <property name="font"> + <font> + <bold>1</bold> + </font> + </property> + <property name="text"> + <string>f</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabelArgY</cstring> + </property> + <property name="text"> + <string>(t) =</string> + </property> + </widget> + </hbox> + </widget> + <widget class="KLineEdit" row="2" column="1"> + <property name="name"> + <cstring>kLineEditYFunction</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip" stdset="0"> + <string>enter an expression</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter an expression for the function. +The dummy variable is t. +Example: sin(t)</string> + </property> + </widget> + <widget class="QLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabelX</cstring> + </property> + <property name="text"> + <string>x</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabelXF</cstring> + </property> + <property name="font"> + <font> + <bold>1</bold> + </font> + </property> + <property name="text"> + <string>f</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabelArgX</cstring> + </property> + <property name="text"> + <string>(t) =</string> + </property> + </widget> + </hbox> + </widget> + </grid> + </widget> + <widget class="QButtonGroup" row="1" column="0"> + <property name="name"> + <cstring>buttonGroup1</cstring> + </property> + <property name="title"> + <string>Extensions</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxHide</cstring> + </property> + <property name="text"> + <string>Hide</string> + </property> + <property name="toolTip" stdset="0"> + <string>hide the plot</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this box if you want to hide the plot of the function.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QFrame" row="3" column="0"> + <property name="name"> + <cstring>frame6</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Colo&r:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kColorButtonColor</cstring> + </property> + </widget> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>kColorButtonColor</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>color of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to choose a color for the plot line.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="text"> + <string>Line &width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kIntNumInputLineWidth</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>kIntNumInputLineWidth</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>width of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Change the width of the plot line in steps of 0.1mm.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>0.1mm</string> + </property> + </widget> + </grid> + </widget> + <widget class="QLayoutWidget" row="4" column="0"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonHelp</cstring> + </property> + <property name="text"> + <string>&Help</string> + </property> + <property name="accel"> + <string>F1</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>apply changes to the list</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to apply the changes to the list of functions.</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>abort without changing anything</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to close the dialog without changing anything.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QFrame" row="2" column="0"> + <property name="name"> + <cstring>frame5</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>&Min:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>min</cstring> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>&Max:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>max</cstring> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>customMaxRange</cstring> + </property> + <property name="text"> + <string>Custom plot maximum t-range:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Customize the maximum plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button and enter the plot maximum range boundary below.</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>customMinRange</cstring> + </property> + <property name="text"> + <string>Custom plot minimum t-range:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Customize the minimum plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button and enter the plot minimum range boundary below.</string> + </property> + </widget> + <widget class="KLineEdit" row="3" column="1"> + <property name="name"> + <cstring>max</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>upper boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the upper boundary of the plot range. Expressions like 2*pi are allowed, too.</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>min</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>lower boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the lower boundary of the plot range. Expressions like 2*pi are allowed, too.</string> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>QEditParametric</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>QEditParametric</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>kLineEditName</sender> + <signal>textChanged(const QString&)</signal> + <receiver>textLabelXF</receiver> + <slot>setText(const QString&)</slot> + </connection> + <connection> + <sender>kLineEditName</sender> + <signal>textChanged(const QString&)</signal> + <receiver>textLabelYF</receiver> + <slot>setText(const QString&)</slot> + </connection> + <connection> + <sender>buttonHelp</sender> + <signal>clicked()</signal> + <receiver>QEditParametric</receiver> + <slot>slotHelp()</slot> + </connection> +</connections> +<tabstops> + <tabstop>kLineEditName</tabstop> + <tabstop>kLineEditXFunction</tabstop> + <tabstop>kLineEditYFunction</tabstop> + <tabstop>checkBoxHide</tabstop> + <tabstop>customMinRange</tabstop> + <tabstop>min</tabstop> + <tabstop>max</tabstop> + <tabstop>kIntNumInputLineWidth</tabstop> + <tabstop>kColorButtonColor</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> + <tabstop>buttonHelp</tabstop> +</tabstops> +<slots> + <slot>slotHelp()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kcolorbutton.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/qeditpolar.ui b/kmplot/kmplot/qeditpolar.ui new file mode 100644 index 00000000..e61c5c6d --- /dev/null +++ b/kmplot/kmplot/qeditpolar.ui @@ -0,0 +1,407 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>QEditPolar</class> +<widget class="QDialog"> + <property name="name"> + <cstring>QEditPolar</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>342</width> + <height>432</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="caption"> + <string>Edit Polar Plot</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="title"> + <string>Definition</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>kLineEditYFunction</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip" stdset="0"> + <string>enter an equation, for instance loop(angle)=ln(angle)</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter an expression for the function. The prefix "r" will be added automatically. +Example: loop(angle)=ln(angle)</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabelR</cstring> + </property> + <property name="text"> + <string>r</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string>Equation:</string> + </property> + </widget> + </grid> + </widget> + <widget class="QButtonGroup" row="1" column="0"> + <property name="name"> + <cstring>buttonGroup1</cstring> + </property> + <property name="title"> + <string>Extensions</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxHide</cstring> + </property> + <property name="text"> + <string>Hide</string> + </property> + <property name="toolTip" stdset="0"> + <string>hide the plot</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this box if you want to hide the plot of the function.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QFrame" row="3" column="0"> + <property name="name"> + <cstring>frame6</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Colo&r:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kColorButtonColor</cstring> + </property> + </widget> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>kColorButtonColor</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>color of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to choose a color for the plot line.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="text"> + <string>Line &width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kIntNumInputLineWidth</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>kIntNumInputLineWidth</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>width of the plot line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Change the width of the plot line in steps of 0.1mm.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>0.1mm</string> + </property> + </widget> + </grid> + </widget> + <widget class="QLayoutWidget" row="4" column="0"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonHelp</cstring> + </property> + <property name="text"> + <string>&Help</string> + </property> + <property name="accel"> + <string>F1</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>apply changes to the list</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to apply the changes to the list of functions.</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>abort without changing anything</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to close the dialog without changing anything.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QFrame" row="2" column="0"> + <property name="name"> + <cstring>frame5</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Max:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>max</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Min:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>min</cstring> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>min</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>lower boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the lower boundary of the plot range. Expressions like 2*pi are allowed, too.</string> + </property> + </widget> + <widget class="KLineEdit" row="3" column="1"> + <property name="name"> + <cstring>max</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>upper boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the upper boundary of the plot range. Expressions like 2*pi are allowed, too.</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>customMinRange</cstring> + </property> + <property name="text"> + <string>Custom plot minimum r-range:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Customize the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button and enter the plot minimum range boundary below.</string> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>customMaxRange</cstring> + </property> + <property name="text"> + <string>Custom plot maximum r-range:</string> + </property> + <property name="toolTip" stdset="0"> + <string>Customize the maximum plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button and enter the plot maximum range boundary below.</string> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>QEditPolar</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>QEditPolar</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>buttonHelp</sender> + <signal>clicked()</signal> + <receiver>QEditPolar</receiver> + <slot>slotHelp()</slot> + </connection> +</connections> +<tabstops> + <tabstop>kLineEditYFunction</tabstop> + <tabstop>checkBoxHide</tabstop> + <tabstop>customMinRange</tabstop> + <tabstop>min</tabstop> + <tabstop>max</tabstop> + <tabstop>kIntNumInputLineWidth</tabstop> + <tabstop>kColorButtonColor</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> + <tabstop>buttonHelp</tabstop> +</tabstops> +<slots> + <slot>slotHelp()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>kcolorbutton.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/qminmax.ui b/kmplot/kmplot/qminmax.ui new file mode 100644 index 00000000..d828cbd6 --- /dev/null +++ b/kmplot/kmplot/qminmax.ui @@ -0,0 +1,142 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>QMinMax</class> +<widget class="QDialog"> + <property name="name"> + <cstring>QMinMax</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>301</width> + <height>339</height> + </rect> + </property> + <property name="caption"> + <string>Find Minimum Point</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KPushButton" row="3" column="0"> + <property name="name"> + <cstring>cmdFind</cstring> + </property> + <property name="text"> + <string>&Find</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QFrame" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>frame5</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lblMin</cstring> + </property> + <property name="text"> + <string>Search between the x-value:</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>lblMax</cstring> + </property> + <property name="text"> + <string>and:</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="KLineEdit" row="1" column="0"> + <property name="name"> + <cstring>min</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + <widget class="KLineEdit" row="3" column="0"> + <property name="name"> + <cstring>max</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>groupBox2</cstring> + </property> + <property name="title"> + <string>Graph</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KListBox" row="0" column="0"> + <property name="name"> + <cstring>list</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The available functions you can search in</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Here you can see all available functions you can use. Select one of them.</string> + </property> + </widget> + </grid> + </widget> + <widget class="KPushButton" row="3" column="1"> + <property name="name"> + <cstring>cmdClose</cstring> + </property> + <property name="text"> + <string>&Close</string> + </property> + <property name="toolTip" stdset="0"> + <string>close the dialog</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Close the dialog and return to the main window.</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cmdParameter</cstring> + </property> + <property name="text"> + <string>Choose Parameter Value...</string> + </property> + <property name="toolTip" stdset="0"> + <string>select the parameter value you want to use</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If the function has any parameter values you must select it here.</string> + </property> + </widget> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kmplot/kmplot/qparametereditor.ui b/kmplot/kmplot/qparametereditor.ui new file mode 100644 index 00000000..619f4fd7 --- /dev/null +++ b/kmplot/kmplot/qparametereditor.ui @@ -0,0 +1,185 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>QParameterEditor</class> +<widget class="QDialog"> + <property name="name"> + <cstring>QParameterEditor</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>395</width> + <height>339</height> + </rect> + </property> + <property name="caption"> + <string>Parameter Editor</string> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QFrame" row="0" column="0"> + <property name="name"> + <cstring>frame3</cstring> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KPushButton" row="1" column="1"> + <property name="name"> + <cstring>cmdEdit</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Change Value...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Change the value of a user-defined constant</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to edit the value of the selected constant. Its name cannot be changed.</string> + </property> + </widget> + <widget class="KListBox" row="0" column="0" rowspan="8" colspan="1"> + <property name="name"> + <cstring>list</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>list of parameter values</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Here you see the list of all parameter values for the function.</string> + </property> + </widget> + <widget class="KPushButton" row="0" column="1"> + <property name="name"> + <cstring>cmdNew</cstring> + </property> + <property name="text"> + <string>&New...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Add a new constant</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click this button to add a new constant.</string> + </property> + </widget> + <widget class="KPushButton" row="7" column="1"> + <property name="name"> + <cstring>cmdClose</cstring> + </property> + <property name="text"> + <string>&Close</string> + </property> + <property name="toolTip" stdset="0"> + <string>Close the dialog</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Close the window and return to the function dialog.</string> + </property> + </widget> + <widget class="KPushButton" row="2" column="1"> + <property name="name"> + <cstring>cmdDelete</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Delete</string> + </property> + <property name="toolTip" stdset="0"> + <string>delete selected constant</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click here to delete the selected constant; it can only be removed if it is not currently used by a plot.</string> + </property> + </widget> + <spacer row="6" column="1"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>80</height> + </size> + </property> + </spacer> + <widget class="KPushButton" row="5" column="1"> + <property name="name"> + <cstring>cmdExport</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>&Export...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Export values to a textfile</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Export values to a textfile. Every value in the parameter list will be written to one line in the file.</string> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer2_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="KPushButton" row="4" column="1"> + <property name="name"> + <cstring>cmdImport</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>&Import...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Import values from a textfile</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Import values from a textfile. Every line in the file is parsed as a value or expression.</string> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kmplot/kmplot/settings.kcfgc b/kmplot/kmplot/settings.kcfgc new file mode 100644 index 00000000..84f83ed6 --- /dev/null +++ b/kmplot/kmplot/settings.kcfgc @@ -0,0 +1,4 @@ +File=kmplot.kcfg +ClassName=Settings +Singleton=true +Mutators=true diff --git a/kmplot/kmplot/settingspagecolor.ui b/kmplot/kmplot/settingspagecolor.ui new file mode 100644 index 00000000..e8e85323 --- /dev/null +++ b/kmplot/kmplot/settingspagecolor.ui @@ -0,0 +1,459 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>SettingsPageColor</class> +<widget class="QWidget"> + <property name="name"> + <cstring>SettingsPageColor</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>415</width> + <height>257</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QTabWidget" row="0" column="0"> + <property name="name"> + <cstring>tabs</cstring> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>&Coords</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>&Axes:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_AxesColor</cstring> + </property> + </widget> + <widget class="KColorButton" row="0" column="1"> + <property name="name"> + <cstring>kcfg_AxesColor</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>select color for the axes</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Specify the color of the axes. The change will appear as soon as you press the OK button.</string> + </property> + </widget> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>kcfg_GridColor</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>select color for the grid</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Specify the color of the grid. The change will appear as soon as you press the OK button.</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>&Grid:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_GridColor</cstring> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>&Default Function Colors</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout19</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout16</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>kcfg_Color1</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 2</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 2. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="KColorButton" row="4" column="1"> + <property name="name"> + <cstring>kcfg_Color4</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 5</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 5. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="KColorButton" row="0" column="1"> + <property name="name"> + <cstring>kcfg_Color0</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 1</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 1. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Function &1:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color1</cstring> + </property> + </widget> + <widget class="KColorButton" row="2" column="1"> + <property name="name"> + <cstring>kcfg_Color2</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 3</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 3. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel3_13</cstring> + </property> + <property name="text"> + <string>Function &3:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color3</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel3_2</cstring> + </property> + <property name="text"> + <string>Function &2:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color2</cstring> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel3_12</cstring> + </property> + <property name="text"> + <string>Function &4:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color4</cstring> + </property> + </widget> + <widget class="KColorButton" row="3" column="1"> + <property name="name"> + <cstring>kcfg_Color3</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 4</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 4. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel3_11</cstring> + </property> + <property name="text"> + <string>Function &5:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color5</cstring> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout17</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel3_9</cstring> + </property> + <property name="text"> + <string>Function &7:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color7</cstring> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel3_8</cstring> + </property> + <property name="text"> + <string>Function &8:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color8</cstring> + </property> + </widget> + <widget class="KColorButton" row="3" column="1"> + <property name="name"> + <cstring>kcfg_Color8</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 9</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 9. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel3_10</cstring> + </property> + <property name="text"> + <string>Function &6:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color6</cstring> + </property> + </widget> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>kcfg_Color6</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 7</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 7. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="KColorButton" row="2" column="1"> + <property name="name"> + <cstring>kcfg_Color7</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 8</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 8. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="KColorButton" row="0" column="1"> + <property name="name"> + <cstring>kcfg_Color5</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 6</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 6. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel3_7</cstring> + </property> + <property name="text"> + <string>Function &9:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color9</cstring> + </property> + </widget> + <widget class="KColorButton" row="4" column="1"> + <property name="name"> + <cstring>kcfg_Color9</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>the default color for function number 10</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The default color for function number 10. Please note that this color setting only affects empty functions, so if you have defined a function at number 1 and you change the color for that number here, the setting will be shown next time you define a new function at number 1.</string> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel3_6</cstring> + </property> + <property name="text"> + <string>Function 1&0:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_Color0</cstring> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </vbox> + </widget> + </widget> + </grid> +</widget> +<tabstops> + <tabstop>tabs</tabstop> + <tabstop>kcfg_AxesColor</tabstop> + <tabstop>kcfg_GridColor</tabstop> + <tabstop>kcfg_Color0</tabstop> + <tabstop>kcfg_Color1</tabstop> + <tabstop>kcfg_Color2</tabstop> + <tabstop>kcfg_Color3</tabstop> + <tabstop>kcfg_Color4</tabstop> + <tabstop>kcfg_Color5</tabstop> + <tabstop>kcfg_Color6</tabstop> + <tabstop>kcfg_Color7</tabstop> + <tabstop>kcfg_Color8</tabstop> + <tabstop>kcfg_Color9</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kmplot/kmplot/settingspagecoords.ui b/kmplot/kmplot/settingspagecoords.ui new file mode 100644 index 00000000..cf2826b3 --- /dev/null +++ b/kmplot/kmplot/settingspagecoords.ui @@ -0,0 +1,769 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>SettingsPageCoords</class> +<widget class="QWidget"> + <property name="name"> + <cstring>SettingsPageCoords</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>420</width> + <height>501</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QTabWidget"> + <property name="name"> + <cstring>tabs</cstring> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>&Axes</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout23</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>kcfg_XRange</cstring> + </property> + <property name="title"> + <string>&X Axis</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1</cstring> + </property> + <property name="text"> + <string>[-8 | +8]</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_3</cstring> + </property> + <property name="text"> + <string>[-5 | +5]</string> + </property> + <property name="buttonGroupId"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_2</cstring> + </property> + <property name="text"> + <string>[0 | +16]</string> + </property> + <property name="buttonGroupId"> + <number>2</number> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_5</cstring> + </property> + <property name="text"> + <string>[0 | +10]</string> + </property> + <property name="buttonGroupId"> + <number>3</number> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_4</cstring> + </property> + <property name="text"> + <string>Custom:</string> + </property> + <property name="buttonGroupId"> + <number>4</number> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout20</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel4_2</cstring> + </property> + <property name="text"> + <string>Max:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>Min:</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>kcfg_XMin</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Custom boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter a valid expression, for instance 2*pi or e/2.</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>kcfg_XMax</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Custom boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter a valid expression, for instance 2*pi or e/2.</string> + </property> + </widget> + </grid> + </widget> + </vbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>kcfg_YRange</cstring> + </property> + <property name="title"> + <string>&Y Axis</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_6</cstring> + </property> + <property name="text"> + <string>[-8 | +8]</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_3_2</cstring> + </property> + <property name="text"> + <string>[-5 | +5]</string> + </property> + <property name="buttonGroupId"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_2_2</cstring> + </property> + <property name="text"> + <string>[0 | +16]</string> + </property> + <property name="buttonGroupId"> + <number>2</number> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_5_2</cstring> + </property> + <property name="text"> + <string>[0 | +10]</string> + </property> + <property name="buttonGroupId"> + <number>3</number> + </property> + <property name="toolTip" stdset="0"> + <string>Predefined plot ranges</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select one of the predefined plot ranges.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1_4_2</cstring> + </property> + <property name="text"> + <string>Custom:</string> + </property> + <property name="buttonGroupId"> + <number>4</number> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout20_2</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel4_2_2</cstring> + </property> + <property name="text"> + <string>Max:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel4_3</cstring> + </property> + <property name="text"> + <string>Min:</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>kcfg_YMin</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Custom boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter a valid expression, for instance 2*pi or e/2.</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>kcfg_YMax</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Custom boundary of the plot range</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter a valid expression, for instance 2*pi or e/2.</string> + </property> + </widget> + </grid> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout24</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel7</cstring> + </property> + <property name="text"> + <string>Axis-line width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_AxesLineWidth</cstring> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>kcfg_AxesLineWidth</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Line width</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel8</cstring> + </property> + <property name="text"> + <string>0.1 mm</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout25</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel9</cstring> + </property> + <property name="text"> + <string>Tic width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_TicWidth</cstring> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>kcfg_TicWidth</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Line width</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel8_2</cstring> + </property> + <property name="text"> + <string>0.1 mm</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout26</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel8_4</cstring> + </property> + <property name="text"> + <string>Tic length:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_TicLength</cstring> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>kcfg_TicLength</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Length of the tic line</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the length of a tic line.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel8_3</cstring> + </property> + <property name="text"> + <string>0.1 mm</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout22</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="1" column="1"> + <property name="name"> + <cstring>kcfg_ShowArrows</cstring> + </property> + <property name="text"> + <string>Show arrows</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>visible arrows at the end of the axes</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this if the axes should have arrows at their ends.</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>kcfg_ShowLabel</cstring> + </property> + <property name="text"> + <string>Show labels</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>visible tic labels</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this if the axes' tics should be labeled.</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>kcfg_ShowExtraFrame</cstring> + </property> + <property name="text"> + <string>Show extra frame</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>visible extra frame</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this if the plot area should be framed by an extra line.</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="1"> + <property name="name"> + <cstring>kcfg_ShowAxes</cstring> + </property> + <property name="text"> + <string>Show axes</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="toolTip" stdset="0"> + <string>visible axes</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this if the axes should be visible.</string> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>30</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>tab</cstring> + </property> + <attribute name="title"> + <string>&Grid</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>kcfg_GridStyle</cstring> + </property> + <property name="title"> + <string>Grid &Style</string> + </property> + <property name="toolTip" stdset="0"> + <string>Available grid styles</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton11</cstring> + </property> + <property name="text"> + <string>None</string> + </property> + <property name="whatsThis" stdset="0"> + <string>No Grid will be plotted.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton12</cstring> + </property> + <property name="text"> + <string>Lines</string> + </property> + <property name="whatsThis" stdset="0"> + <string>A line for every tic.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton13</cstring> + </property> + <property name="text"> + <string>Crosses</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Only little crosses in the plot area.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton14</cstring> + </property> + <property name="text"> + <string>Polar</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Circles around the Origin.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout24</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel5</cstring> + </property> + <property name="text"> + <string>Line &width:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_GridLineWidth</cstring> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>kcfg_GridLineWidth</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="toolTip" stdset="0"> + <string>Width for the grid lines</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the width of the grid lines.</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel6</cstring> + </property> + <property name="text"> + <string>0.1 mm</string> + </property> + </widget> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </vbox> + </widget> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>radioButton1_4</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_XMin</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>radioButton1_4</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_XMin</receiver> + <slot>setFocus()</slot> + </connection> + <connection> + <sender>radioButton1_4</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_XMax</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>radioButton1_4_2</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_YMin</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>radioButton1_4_2</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_YMin</receiver> + <slot>setFocus()</slot> + </connection> + <connection> + <sender>radioButton1_4_2</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_YMax</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>kcfg_ShowAxes</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_ShowArrows</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>tabs</tabstop> + <tabstop>radioButton1</tabstop> + <tabstop>kcfg_XMin</tabstop> + <tabstop>kcfg_XMax</tabstop> + <tabstop>radioButton1_6</tabstop> + <tabstop>kcfg_YMin</tabstop> + <tabstop>kcfg_YMax</tabstop> + <tabstop>kcfg_AxesLineWidth</tabstop> + <tabstop>kcfg_ShowLabel</tabstop> + <tabstop>kcfg_TicWidth</tabstop> + <tabstop>kcfg_TicLength</tabstop> + <tabstop>radioButton11</tabstop> + <tabstop>radioButton12</tabstop> + <tabstop>radioButton13</tabstop> + <tabstop>radioButton14</tabstop> + <tabstop>kcfg_GridLineWidth</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/settingspagefonts.ui b/kmplot/kmplot/settingspagefonts.ui new file mode 100644 index 00000000..e5f80ccd --- /dev/null +++ b/kmplot/kmplot/settingspagefonts.ui @@ -0,0 +1,128 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>SettingsPageFonts</class> +<widget class="QWidget"> + <property name="name"> + <cstring>SettingsPageFonts</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>483</width> + <height>147</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="3" column="2"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>110</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel11</cstring> + </property> + <property name="text"> + <string>&Header table:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_HeaderTableFont</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel10</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Axis &font:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_AxesFont</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel10_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Axis font &size:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_AxesFont</cstring> + </property> + </widget> + <widget class="KFontCombo" row="0" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>kcfg_AxesFont</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>the font for the axis</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select the font you want to use for the axis labels. If you cannot see the labels, check that you have enabled "Show labels" in the coordinate setting dialog.</string> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="1"> + <property name="name"> + <cstring>kcfg_AxesFontSize</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>The font size for the axis</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Here you set the font size for the axis</string> + </property> + </widget> + <widget class="KFontCombo" row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>kcfg_HeaderTableFont</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>the font for the header table</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Select the font you want to use in the header table. The header table can be included when you are printing a graph.</string> + </property> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kfontcombo.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kfontcombo.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/settingspageprecision.ui b/kmplot/kmplot/settingspageprecision.ui new file mode 100644 index 00000000..25f732ce --- /dev/null +++ b/kmplot/kmplot/settingspageprecision.ui @@ -0,0 +1,276 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>SettingsPagePrecision</class> +<widget class="QDialog"> + <property name="name"> + <cstring>SettingsPagePrecision</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>301</width> + <height>401</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="4" column="0"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>29</height> + </size> + </property> + </spacer> + <widget class="QGroupBox" row="3" column="0"> + <property name="name"> + <cstring>groupBox3</cstring> + </property> + <property name="title"> + <string>Zoom</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Zoom in by:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_zoomStep</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_2_2</cstring> + </property> + <property name="text"> + <string>Zoom out by:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_zoomStep</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>kcfg_zoomInStep</cstring> + </property> + <property name="value"> + <number>25</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="maxValue"> + <number>100</number> + </property> + <property name="referencePoint"> + <number>5</number> + </property> + <property name="suffix"> + <string>%</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The value the zoom-in tool should use.</string> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="1"> + <property name="name"> + <cstring>kcfg_zoomOutStep</cstring> + </property> + <property name="value"> + <number>25</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="maxValue"> + <number>100</number> + </property> + <property name="referencePoint"> + <number>5</number> + </property> + <property name="suffix"> + <string>%</string> + </property> + <property name="whatsThis" stdset="0"> + <string>The value the zoom-out tool should use.</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="2" column="0"> + <property name="name"> + <cstring>groupBox2</cstring> + </property> + <property name="title"> + <string>Background Color</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KColorButton"> + <property name="name"> + <cstring>kcfg_backgroundcolor</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Color for the plot area behind the grid.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Click on the button the choose the color of the background. This option has no effect on printing nor export.</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>81</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QButtonGroup" row="1" column="0"> + <property name="name"> + <cstring>kcfg_anglemode</cstring> + </property> + <property name="title"> + <string>Angle Mode</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton1</cstring> + </property> + <property name="text"> + <string>&Radian</string> + </property> + <property name="toolTip" stdset="0"> + <string>Trigonometric functions use radian mode for angles.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button to use radian mode to measure angles. This is important for trigonometric functions only.</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>radioButton2</cstring> + </property> + <property name="text"> + <string>&Degree</string> + </property> + <property name="toolTip" stdset="0"> + <string>Trigonometric functions use degree mode for angles.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Check this button to use degree mode to measure angles. This is important for trigonometric functions only.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="title"> + <string>Precision</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Points per pixel:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_relativeStepWidth</cstring> + </property> + </widget> + <widget class="KDoubleNumInput"> + <property name="name"> + <cstring>kcfg_stepWidth</cstring> + </property> + <property name="value"> + <number>1</number> + </property> + <property name="minValue"> + <number>0.1</number> + </property> + <property name="toolTip" stdset="0"> + <string>How many points per pixel shall be calculated.</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Enter the amount of points per pixel which shall be calculated. For slow computers or very complex plots use higher values.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>kcfg_useRelativeStepWidth</cstring> + </property> + <property name="text"> + <string>&Use relative step width</string> + </property> + <property name="toolTip" stdset="0"> + <string>Use the same precision independent of the window's size</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If relative step width is set to true, the step width will be adapted to the size of the window.</string> + </property> + </widget> + </vbox> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kmplot/kmplot/settingspagescaling.ui b/kmplot/kmplot/settingspagescaling.ui new file mode 100644 index 00000000..222359ba --- /dev/null +++ b/kmplot/kmplot/settingspagescaling.ui @@ -0,0 +1,415 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>SettingsPageScaling</class> +<widget class="QWidget"> + <property name="name"> + <cstring>SettingsPageScaling</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>450</width> + <height>345</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout35</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="title"> + <string>X-Axis</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>textLabel13</cstring> + </property> + <property name="text"> + <string>Scaling:</string> + </property> + </widget> + <widget class="Line" row="2" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>line1</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QLabel" row="3" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>textLabel13_2</cstring> + </property> + <property name="text"> + <string>Printing:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel12</cstring> + </property> + <property name="text"> + <string>1 tic =</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_XScaling</cstring> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel12_2</cstring> + </property> + <property name="text"> + <string>1 tic =</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_XPrinting</cstring> + </property> + </widget> + <widget class="KComboBox" row="4" column="1"> + <item> + <property name="text"> + <string>10</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>2</string> + </property> + </item> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>0.5</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/2</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/3</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/4</string> + </property> + </item> + <property name="name"> + <cstring>kcfg_XPrinting</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>set the x-axis' printing scaling</string> + </property> + <property name="whatsThis" stdset="0"> + <string>This is similar to the setting above, but this sets the distance between two x-axis-grids when printing or drawing on the screen.</string> + </property> + </widget> + <widget class="QLabel" row="4" column="2"> + <property name="name"> + <cstring>textLabel14</cstring> + </property> + <property name="text"> + <string>cm</string> + </property> + </widget> + <widget class="KComboBox" row="1" column="1"> + <item> + <property name="text"> + <string>10</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>2</string> + </property> + </item> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>0.5</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/2</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/3</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/4</string> + </property> + </item> + <item> + <property name="text"> + <string>automatic</string> + </property> + </item> + <property name="name"> + <cstring>kcfg_XScaling</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>set the x-axis' scaling</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Choose how many units apart the x-axis tics will be, and therefore, how far apart grid lines will be drawn.</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox1_2</cstring> + </property> + <property name="title"> + <string>Y-Axis</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>textLabel13_3</cstring> + </property> + <property name="text"> + <string>Scaling:</string> + </property> + </widget> + <widget class="Line" row="3" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>line1_2</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QLabel" row="4" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>textLabel13_2_2</cstring> + </property> + <property name="text"> + <string>Printing:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0" rowspan="2" colspan="2"> + <property name="name"> + <cstring>textLabel12_3</cstring> + </property> + <property name="text"> + <string>1 tic =</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_YScaling</cstring> + </property> + </widget> + <widget class="QLabel" row="5" column="0"> + <property name="name"> + <cstring>textLabel12_2_2</cstring> + </property> + <property name="text"> + <string>1 tic =</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_YPrinting</cstring> + </property> + </widget> + <widget class="KComboBox" row="5" column="1"> + <item> + <property name="text"> + <string>10</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>2</string> + </property> + </item> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>0.5</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/2</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/3</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/4</string> + </property> + </item> + <property name="name"> + <cstring>kcfg_YPrinting</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>set the y-axis' scaling</string> + </property> + <property name="whatsThis" stdset="0"> + <string>This is similar to the setting above, but this sets the distance between two y-axis-grids when printing or drawing on the screen.</string> + </property> + </widget> + <widget class="QLabel" row="5" column="2"> + <property name="name"> + <cstring>textLabel14_2</cstring> + </property> + <property name="text"> + <string>cm</string> + </property> + </widget> + <widget class="KComboBox" row="2" column="1"> + <item> + <property name="text"> + <string>10</string> + </property> + </item> + <item> + <property name="text"> + <string>5</string> + </property> + </item> + <item> + <property name="text"> + <string>2</string> + </property> + </item> + <item> + <property name="text"> + <string>1</string> + </property> + </item> + <item> + <property name="text"> + <string>0.5</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/2</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/3</string> + </property> + </item> + <item> + <property name="text"> + <string>pi/4</string> + </property> + </item> + <item> + <property name="text"> + <string>automatic</string> + </property> + </item> + <property name="name"> + <cstring>kcfg_YScaling</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>set the y-axis' scaling</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Choose how many units apart the y-axis tics will be, and therefore, how far apart grid lines will be drawn.</string> + </property> + </widget> + </grid> + </widget> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>91</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<tabstops> + <tabstop>kcfg_XScaling</tabstop> + <tabstop>kcfg_XPrinting</tabstop> + <tabstop>kcfg_YScaling</tabstop> + <tabstop>kcfg_YPrinting</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kmplot/kmplot/sliderwindow.ui b/kmplot/kmplot/sliderwindow.ui new file mode 100644 index 00000000..deff716a --- /dev/null +++ b/kmplot/kmplot/sliderwindow.ui @@ -0,0 +1,87 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>SliderWindow</class> +<widget class="QDialog"> + <property name="name"> + <cstring>SliderWindow</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>273</width> + <height>51</height> + </rect> + </property> + <property name="caption"> + <string>Slider</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QSlider" row="0" column="0"> + <property name="name"> + <cstring>slider</cstring> + </property> + <property name="minimumSize"> + <size> + <width>200</width> + <height>0</height> + </size> + </property> + <property name="cursor"> + <cursor>13</cursor> + </property> + <property name="focusPolicy"> + <enum>StrongFocus</enum> + </property> + <property name="maxValue"> + <number>100</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="tickmarks"> + <enum>Below</enum> + </property> + <property name="tickInterval"> + <number>10</number> + </property> + </widget> + <widget class="QLabel" row="0" column="1"> + <property name="name"> + <cstring>value</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>slider</sender> + <signal>valueChanged(int)</signal> + <receiver>value</receiver> + <slot>setNum(int)</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kmplot/kmplot/x-kmplot.desktop b/kmplot/kmplot/x-kmplot.desktop new file mode 100644 index 00000000..06093db0 --- /dev/null +++ b/kmplot/kmplot/x-kmplot.desktop @@ -0,0 +1,63 @@ +[Desktop Entry] +Comment=KmPlot File +Comment[af]=KmPlot lêer +Comment[be]=Файл KmPlot +Comment[bg]=Файл KmPlot +Comment[bn]=কে-এমপ্লট ফাইল +Comment[br]=Restr KmPlot +Comment[bs]=KmPlot datoteka +Comment[ca]=Fitxer de KmPlot +Comment[cs]=KMPlot soubor +Comment[csb]=Lopk KmPlot +Comment[cy]=Ffeil KmPlot +Comment[da]=KmPlot-fil +Comment[de]=KmPlot-Datei +Comment[el]=Αρχείο του KmPlot +Comment[eo]=KmPlota dosiero +Comment[es]=Archivo de KmPlot +Comment[et]=KmPloti fail +Comment[eu]=KmPlot fitxategia +Comment[fi]=KGeo-kaavio +Comment[fr]=Fichier KmPlot +Comment[ga]=Comhad KmPlot +Comment[gl]=Ficheiro de KmPlot +Comment[he]=KmPlot קובץ +Comment[hi]=केएम-प्लॉट फ़ाइल +Comment[hr]=KmPlot datoteka +Comment[hu]=KmPlot-fájl +Comment[is]=KmPlot-skrá +Comment[it]=File di KmPlot +Comment[ja]=KmPlot ファイル +Comment[ka]=KmPlot ფაილი +Comment[km]=ឯកសារ KmPlot +Comment[lt]=KmPlot byla +Comment[ms]=Fail KmPlot +Comment[nb]=KmPlot-fil +Comment[nds]=KmPlot-Datei +Comment[ne]=KmPlot फाइल +Comment[nl]=KmPlot-bestand +Comment[nn]=KmPlot-fil +Comment[pl]=Plik KmPlot +Comment[pt]=Ficheiro do KmPlot +Comment[pt_BR]=Arquivo do KMPlot +Comment[ru]=Файл KmPlot +Comment[sk]=Súbor KmPlot +Comment[sl]=Datoteka KmPlot +Comment[sr]=Фајл KmPlot-а +Comment[sr@Latn]=Fajl KmPlot-a +Comment[sv]=Kmplot-fil +Comment[ta]= கேஎம்பிளாட் கோப்பு +Comment[tg]=Файли KmPlot +Comment[tr]=KmPlot Dosyası +Comment[uk]=Файл KmPlot +Comment[vi]=Tập tin Đồ thị K +Comment[zh_CN]=KmPlot 文件 +Comment[zh_TW]=KmPlot 檔案 +Icon=kmplot +Type=MimeType +MimeType=application/x-kmplot +Patterns=*.fkt + +[Property::X-KDE-text] +Type=bool +Value=true diff --git a/kmplot/kmplot/xparser.cpp b/kmplot/kmplot/xparser.cpp new file mode 100644 index 00000000..cc618e13 --- /dev/null +++ b/kmplot/kmplot/xparser.cpp @@ -0,0 +1,826 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +// KDE includes +#include <dcopclient.h> +#include <kapplication.h> +#include <kglobal.h> +#include <kinputdialog.h> +#include <klocale.h> +#include <kmessagebox.h> + +// local includes +#include "xparser.h" + +XParser::XParser(bool &mo) : DCOPObject("Parser"), Parser(), m_modified(mo) +{ + // setup slider support + setDecimalSymbol( KGlobal::locale()->decimalSymbol() ); +} + +XParser::~XParser() +{ +} + +bool XParser::getext( Ufkt *item, const QString fstr ) +{ + bool errflg = false; + int p1, p2, p3, pe; + QString tstr; + pe = fstr.length(); + if ( fstr.find( 'N' ) != -1 ) + item->f_mode = false; + else + { + if ( fstr.find( "A1" ) != -1 ) + item->f1_mode = true; + if ( fstr.find( "A2" ) != -1 ) + item->f2_mode = true; + } + switch ( fstr[0].latin1() ) + { + case 'x': + case 'y': + case 'r': + item->f1_mode = item->f2_mode = false; + } + + p1 = fstr.find( "D[" ); + if ( p1 != -1 ) + { + p1 += 2; + const QString str = fstr.mid( p1, pe - p1); + p2 = str.find(','); + p3 = str.find(']'); + if ( p2 > 0 && p2 < p3 ) + { + tstr = str.left( p2 ); + item->dmin = eval( tstr ); + if ( parserError(false) ) + errflg = true; + tstr = str.mid( p2 + 1, p3 - p2 - 1 ); + item->dmax = eval( tstr ); + if ( parserError(false) ) + errflg = true; + if ( item->dmin > item->dmax ) + errflg = true; + } + else + errflg = true; + } + p1 = fstr.find( "P[" ); + if ( p1 != -1 ) + { + int i = 0; + p1 += 2; + QString str = fstr.mid( p1, 1000); + p3 = str.find( ']' ); + do + { + p2 = str.find( ',' ); + if ( p2 == -1 || p2 > p3 ) + p2 = p3; + tstr = str.left( p2++ ); + str = str.mid( p2, 1000 ); + item->parameters.append( ParameterValueItem(tstr, eval( tstr )) ); + if ( parserError(false) ) + { + errflg = true; + break; + } + p3 -= p2; + } + while ( p3 > 0 && i < 10 ); + } + + if ( errflg ) + { + KMessageBox::error( 0, i18n( "Error in extension." ) ); + return false; + } + else + return true; +} + +double XParser::a1fkt( Ufkt *u_item, double x, double h ) +{ + return ( fkt(u_item, x + h ) - fkt( u_item, x ) ) / h; +} + +double XParser::a2fkt( Ufkt *u_item, double x, double h ) +{ + return ( fkt( u_item, x + h + h ) - 2 * fkt( u_item, x + h ) + fkt( u_item, x ) ) / h / h; +} + +void XParser::findFunctionName(QString &function_name, int const id, int const type) +{ + char last_character; + int pos; + if ( function_name.length()==2/*type == XParser::Polar*/ || type == XParser::ParametricX || type == XParser::ParametricY) + pos=1; + else + pos=0; + for ( ; ; ++pos) + { + last_character = 'f'; + for (bool ok=true; last_character<'x'; ++last_character) + { + if ( pos==0 && last_character == 'r') continue; + function_name.at(pos)=last_character; + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + if (it == ufkt.begin() && it->fname.isEmpty() ) continue; + if ( it->fstr.startsWith(function_name+'(') && (int)it->id!=id) //check if the name is free + ok = false; + } + if ( ok) //a free name was found + { + //kdDebug() << "function_name:" << function_name << endl; + return; + } + ok = true; + } + function_name.at(pos)='f'; + function_name.append('f'); + } + function_name = "e"; //this should never happen +} + +void XParser::fixFunctionName( QString &str, int const type, int const id) +{ + if ( str.startsWith( "y=" ) ) //we find a free function name + { + str.remove( 0, 2 ); + str.prepend("(x)="); + QString function_name; + findFunctionName(function_name, id, type); + str.prepend( function_name ); + } + + int p1=str.find('('); + int p2=str.find(')'); + if( p1>=0 && str.at(p2+1)=='=') + { + if ( type == XParser::Polar && str.at(0)!='r' ) + { + if (str.at(0)=='(') + { + str.prepend('f'); + p1++; + p2++; + } + str.prepend('r'); + p1++; + p2++; + } + QString const fname = str.left(p1); + for ( QValueVector<Ufkt>::iterator it = ufkt.begin(); it!=ufkt.end(); ++it ) + { + if (it->fname == fname) + { + str = str.mid(p1,str.length()-1); + QString function_name; + if ( type == XParser::Polar ) + function_name = "rf"; + else if ( type == XParser::ParametricX ) + function_name = "x"; + else if ( type == XParser::ParametricY ) + function_name = "y"; + else + function_name = "f"; + findFunctionName(function_name, id, type); + str.prepend( function_name ); + return; + } + } + } + else if ( p1==-1 || !str.at(p1+1).isLetter() || p2==-1 || str.at(p2+1 )!= '=') + { + QString function_name; + if ( type == XParser::Polar ) + function_name = "rf"; + else if ( type == XParser::ParametricX ) + function_name = "xf"; + else if ( type == XParser::ParametricY ) + function_name = "yf"; + else + function_name = "f"; + str.prepend("(x)="); + findFunctionName(function_name, id, type); + str.prepend( function_name ); + } +} + +double XParser::euler_method(const double x, const QValueVector<Ufkt>::iterator it) +{ + double const y = it->oldy + ((x-it->oldx) * it->oldyprim); + it->oldy = y; + it->oldx = x; + it->oldyprim = fkt( it, x ); //yprim; + return y; +} + +QRgb XParser::defaultColor(int function) +{ + switch ( function%10 ) + { + case 0: + return Settings::color0().rgb(); + break; + case 1: + return Settings::color1().rgb(); + break; + case 2: + return Settings::color2().rgb(); + break; + case 3: + return Settings::color3().rgb(); + break; + case 4: + return Settings::color4().rgb(); + break; + case 5: + return Settings::color5().rgb(); + break; + case 6: + return Settings::color6().rgb(); + break; + case 7: + return Settings::color7().rgb(); + break; + case 8: + return Settings::color8().rgb(); + break; + case 9: + return Settings::color9().rgb(); + break; + default: + return Settings::color0().rgb(); + break; + } +} + +void XParser::prepareAddingFunction(Ufkt *temp) +{ + temp->color = temp->f1_color = temp->f2_color = temp->integral_color = defaultColor(getNextIndex() ); + temp->linewidth = temp->f1_linewidth = temp->f2_linewidth = temp->integral_linewidth = linewidth0; + temp->f_mode = true; + temp->f1_mode = false; + temp->f2_mode = false; + temp->integral_mode = false; + temp->integral_precision = Settings::stepWidth(); + temp->usecustomxmin = false; + temp->usecustomxmax = false; + temp->use_slider = -1; + //TODO temp->slider_min = 0; temp->slider_max = 50; + +} +int XParser::getNextIndex() +{ + //return ufkt.count(); + return getNewId(); +} + +QStringList XParser::listFunctionNames() +{ + QStringList list; + for( QValueVector<Ufkt>::iterator it = ufkt.begin(); it != ufkt.end(); ++it) + { + list.append(it->fname); + } + return list; +} + +bool XParser::functionFVisible(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + return ufkt[ix].f_mode; +} +bool XParser::functionF1Visible(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + return ufkt[ix].f1_mode; +} +bool XParser::functionF2Visible(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + return ufkt[ix].f2_mode; +} +bool XParser::functionIntVisible(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + return ufkt[ix].integral_mode; +} + +bool XParser::setFunctionFVisible(bool visible, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].f_mode = visible; + m_modified = true; + return true; +} +bool XParser::setFunctionF1Visible(bool visible, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].f1_mode = visible; + m_modified = true; + return true; +} +bool XParser::setFunctionF2Visible(bool visible, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].f2_mode = visible; + m_modified = true; + return true; +} +bool XParser::setFunctionIntVisible(bool visible, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].integral_mode = visible; + m_modified = true; + return true; +} + +QString XParser::functionStr(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return ""; + return ufkt[ix].fstr; +} + +QColor XParser::functionFColor(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return QColor(); + return QColor(ufkt[ix].color); +} +QColor XParser::functionF1Color(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return QColor(); + return QColor(ufkt[ix].f1_color); +} +QColor XParser::functionF2Color(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return QColor(); + return QColor(ufkt[ix].f2_color); +} +QColor XParser::functionIntColor(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return QColor(); + return QColor(ufkt[ix].integral_color); +} +bool XParser::setFunctionFColor(const QColor &color, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].color = color.rgb(); + m_modified = true; + return true; +} +bool XParser::setFunctionF1Color(const QColor &color, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].color = color.rgb(); + m_modified = true; + return true; +} +bool XParser::setFunctionF2Color(const QColor &color, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].color = color.rgb(); + m_modified = true; + return true; +} +bool XParser::setFunctionIntColor(const QColor &color, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].color = color.rgb(); + m_modified = true; + return true; +} + +int XParser::functionFLineWidth(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return 0; + return ufkt[ix].linewidth; +} +int XParser::functionF1LineWidth(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return int(); + return ufkt[ix].f1_linewidth; +} +int XParser::functionF2LineWidth(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return int(); + return ufkt[ix].f2_linewidth; +} +int XParser::functionIntLineWidth(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return int(); + return ufkt[ix].integral_linewidth; +} +bool XParser::setFunctionFLineWidth(int linewidth, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].linewidth = linewidth; + m_modified = true; + return true; +} +bool XParser::setFunctionF1LineWidth(int linewidth, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].f1_linewidth = linewidth; + m_modified = true; + return true; +} +bool XParser::setFunctionF2LineWidth(int linewidth, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].f2_linewidth = linewidth; + m_modified = true; + return true; +} +bool XParser::setFunctionIntLineWidth(int linewidth, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].integral_linewidth = linewidth; + m_modified = true; + return true; +} + +QString XParser::functionMinValue(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return int(); + return ufkt[ix].str_dmin; +} + +bool XParser::setFunctionMinValue(const QString &min, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].str_dmin = min; + m_modified = true; + return true; +} + +QString XParser::functionMaxValue(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return int(); + return ufkt[ix].str_dmax; +} + +bool XParser::setFunctionMaxValue(const QString &max, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].str_dmax = max; + m_modified = true; + return true; +} + +QString XParser::functionStartXValue(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return int(); + return ufkt[ix].str_startx; +} + +bool XParser::setFunctionStartXValue(const QString &x, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].str_startx = x; + m_modified = true; + return true; +} + +QString XParser::functionStartYValue(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return int(); + return ufkt[ix].str_starty; +} + +bool XParser::setFunctionStartYValue(const QString &y, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + ufkt[ix].str_starty = y; + m_modified = true; + return true; +} + +QStringList XParser::functionParameterList(uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return QStringList(); + Ufkt *item = &ufkt[ix]; + QStringList str_parameter; + for ( QValueList<ParameterValueItem>::iterator it = item->parameters.begin(); it != item->parameters.end(); ++it) + str_parameter.append( (*it).expression); + return str_parameter; +} +bool XParser::functionAddParameter(const QString &new_parameter, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + Ufkt *tmp_ufkt = &ufkt[ix]; + for ( QValueList<ParameterValueItem>::iterator it = tmp_ufkt->parameters.begin(); it != tmp_ufkt->parameters.end(); ++it) + if ( (*it).expression == new_parameter) //check if the parameter already exists + return false; + + double const result = eval(new_parameter); + if ( parserError(false) != 0) + return false; + tmp_ufkt->parameters.append( ParameterValueItem(new_parameter,result) ); + m_modified = true; + return true; +} +bool XParser::functionRemoveParameter(const QString &remove_parameter, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + Ufkt *tmp_ufkt = &ufkt[ix]; + + bool found = false; + QValueList<ParameterValueItem>::iterator it; + for ( it = tmp_ufkt->parameters.begin(); it != tmp_ufkt->parameters.end(); ++it) + if ( (*it).expression == remove_parameter) //check if the parameter already exists + { + found = true; + break; + } + if (!found) + return false; + tmp_ufkt->parameters.remove(it); + m_modified = true; + return true; +} +int XParser::addFunction(const QString &f_str) +{ + QString added_function(f_str); + int const pos = added_function.find(';'); + if (pos!=-1) + added_function = added_function.left(pos); + + fixFunctionName(added_function); + if ( added_function.at(0)== 'x' || added_function.at(0)== 'y') //TODO: Make it possible to define parametric functions + return -1; + if ( added_function.contains('y') != 0) + return -1; + int const id = addfkt( added_function ); + if (id==-1) + return -1; + Ufkt *tmp_ufkt = &ufkt.last(); + prepareAddingFunction(tmp_ufkt); + if ( pos!=-1 && !getext( tmp_ufkt, f_str ) ) + { + Parser::delfkt( tmp_ufkt ); + return -1; + } + m_modified = true; + return id; +} + +bool XParser::addFunction(const QString &fstr_const, bool f_mode, bool f1_mode, bool f2_mode, bool integral_mode, bool integral_use_precision, int linewidth, int f1_linewidth, int f2_linewidth, int integral_linewidth, const QString &str_dmin, const QString &str_dmax, const QString &str_startx, const QString &str_starty, double integral_precision, QRgb color, QRgb f1_color, QRgb f2_color, QRgb integral_color, QStringList str_parameter, int use_slider) +{ + QString fstr(fstr_const); + switch ( fstr.at(0).latin1() ) + { + case 'r': + { + fixFunctionName(fstr, XParser::Polar); + break; + } + case 'x': + fixFunctionName(fstr, XParser::ParametricX); + break; + case 'y': + fixFunctionName(fstr, XParser::ParametricY); + break; + default: + fixFunctionName(fstr, XParser::Function); + break; + } + int const id = addfkt( fstr ); + if ( id==-1 ) + return false; + Ufkt *added_function = &ufkt.last(); + added_function->f_mode = f_mode; + added_function->f1_mode = f1_mode; + added_function->f2_mode = f2_mode; + added_function->integral_mode = integral_mode; + added_function->integral_use_precision = integral_use_precision; + added_function->linewidth = linewidth; + added_function->f1_linewidth = f1_linewidth; + added_function->f2_linewidth = f2_linewidth; + added_function->integral_linewidth = integral_linewidth; + + if ( str_dmin.isEmpty() ) + added_function->usecustomxmin = false; + else //custom minimum range + { + added_function->usecustomxmin = true; + added_function->str_dmin = str_dmin; + added_function->dmin = eval(str_dmin); + } + if ( str_dmax.isEmpty() ) + added_function->usecustomxmax = false; + else //custom maximum range + { + added_function->usecustomxmax = true; + added_function->str_dmax = str_dmax; + added_function->dmax = eval(str_dmax); + } + added_function->str_startx = str_startx; + added_function->str_starty = str_starty; + if ( !str_starty.isEmpty() ) + added_function->starty = eval(str_starty); + if ( !str_startx.isEmpty() ) + added_function->startx = eval(str_startx); + added_function->oldx = 0; + added_function->integral_precision = integral_precision; + added_function->color = color; + added_function->f1_color = f1_color; + added_function->f2_color = f2_color; + added_function->integral_color = integral_color; + added_function->use_slider = use_slider; + for( QStringList::Iterator it = str_parameter.begin(); it != str_parameter.end(); ++it ) + { + double result = eval(*it); + if ( parserError(false) != 0) + continue; + added_function->parameters.append( ParameterValueItem(*it, result ) ); + } + m_modified = true; + return true; +} + +bool XParser::setFunctionExpression(const QString &f_str, uint id) +{ + int const ix = ixValue(id); + if (ix==-1) + return false; + Ufkt *tmp_ufkt = &ufkt[ix]; + QString const old_fstr = tmp_ufkt->fstr; + QString const fstr_begin = tmp_ufkt->fstr.left(tmp_ufkt->fstr.find('=')+1); + tmp_ufkt->fstr = fstr_begin+f_str; + reparse(tmp_ufkt); + if ( parserError(false) != 0) + { + tmp_ufkt->fstr = old_fstr; + reparse(tmp_ufkt); + return false; + } + return true; +} + +bool XParser::sendFunction(int id, const QString &dcopclient_target) +{ + QCStringList cstr_list = kapp->dcopClient()->registeredApplications(); + QStringList str_list; + for ( QCStringList::iterator it = cstr_list.begin(); it!=cstr_list.end();++it ) + if ( QString(*it).startsWith("kmplot") && *it!=kapp->dcopClient()->appId() ) + str_list.append(*it); + if ( str_list.isEmpty() ) + { + KMessageBox::error(0, i18n("There are no other Kmplot instances running")); + return false; + } + + Ufkt *item = &ufkt[ixValue(id)]; + kdDebug() << "Transferring " << item->fname.latin1() << endl; + QString str_result; + if ( dcopclient_target.isEmpty() && item->fname.at(0) == 'y' ) + return false; + else if ( dcopclient_target.isEmpty() ) + { + bool ok; + str_result = KInputDialog::getItem(i18n("kmplot"), i18n("Choose which KmPlot instance\nyou want to copy the function to:"), str_list, 0, false, &ok); + if (!ok) + return false; + } + else + str_result = dcopclient_target; + + QByteArray parameters; + QDataStream arg( parameters, IO_WriteOnly); + + QString str_dmin; + if (!item->usecustomxmin) + str_dmin = item->str_dmin; + QString str_dmax; + if (!item->usecustomxmax) + str_dmax = item->str_dmax; + + QStringList str_parameters; + for ( QValueList<ParameterValueItem>::Iterator it = item->parameters.begin(); it != item->parameters.end(); ++it ) + str_parameters.append( (*it).expression); + arg << item->fstr << item->f_mode << item->f1_mode << item->f2_mode << item->integral_mode << item->integral_use_precision << item->linewidth << item->f1_linewidth << item->f2_linewidth << item->integral_linewidth << str_dmin << str_dmax << item->str_startx << item->str_starty << item->integral_precision << item->color << item->f1_color << item->f2_color << item->integral_color << str_parameters << item->use_slider; + QByteArray replay_data; + QCString replay_type; + bool ok = kapp->dcopClient()->call( str_result.utf8(), "Parser", "addFunction(QString,bool,bool,bool,bool,bool,int,int,int,int,QString,QString,QString,QString,double,QRgb,QRgb,QRgb,QRgb,QStringList,int)", parameters, replay_type, replay_data, false); + if (!ok) + { + KMessageBox::error(0, i18n("An error appeared during the transfer")); + return false; + } + + QDataStream replay_arg(replay_data, IO_ReadOnly); + bool result; + replay_arg >> result; + if (!result) + { + KMessageBox::error(0, i18n("An error appeared during the transfer")); + return false; + } + + kapp->dcopClient()->send(str_result.utf8(), "View","drawPlot()",QByteArray() ); //update the other window + + if (item->fname.at(0) == 'x') // a parametric function + return sendFunction(id+1, str_result); + else + return true; +} diff --git a/kmplot/kmplot/xparser.h b/kmplot/kmplot/xparser.h new file mode 100644 index 00000000..78c4463e --- /dev/null +++ b/kmplot/kmplot/xparser.h @@ -0,0 +1,146 @@ +/* +* KmPlot - a math. function plotter for the KDE-Desktop +* +* Copyright (C) 1998, 1999 Klaus-Dieter Möller +* 2000, 2002 kd.moeller@t-online.de +* +* This file is part of the KDE Project. +* KmPlot is part of the KDE-EDU Project. +* +* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef xparser_included +#define xparser_included + +#define SLIDER_COUNT 4 + +// Qt includes +#include <kdebug.h> + +// local includes +#include "parser.h" +#include "settings.h" + +/** + * @short Extended parser class. + * + * This class extends the parser class to support derivatives, + * draw options like color and line width and so on. + */ +class XParser : public Parser +{ +public: + XParser(bool &); + ~XParser(); + /// Evaluates the 1st dreivative of the function with intex \a ix + double a1fkt( Ufkt *u_item , double, double h = 1e-3 ); + /// Evaluates the 2nd dreivative of the function with intex \a ix + double a2fkt( Ufkt *, double, double h = 1e-3 ); + /// calculate euler's method when drawing a numeric prime-function + double euler_method(const double, const QValueVector<Ufkt>::iterator); + + /// Line width default + int linewidth0; + QRgb defaultColor(int function); + + enum { Function, Polar, ParametricX, ParametricY }; ///types of functions + ///Returns an unused function name if it is needed + void fixFunctionName(QString &, int const = XParser::Function , int const=-1); + + /// Returns the index for the next function. + int getNextIndex(); + /// Fill item with default values (e.g color, linewidth ) + void prepareAddingFunction(Ufkt *item); + + /// Interpretates the extended function string (only used by the old file format) + bool getext( Ufkt *, const QString ); + + /// Send a function to an other instance of Kmplot. Returns true if it success, otherwise false + bool sendFunction(int id, const QString &dcopclient_target=""); + + /// Functions for the DCOP interface: + + /// Returns a list with all functions + QStringList listFunctionNames(); + + /// Returns true if the graph is visible, otherwise false. + bool functionFVisible(uint id); + bool functionF1Visible(uint id); + bool functionF2Visible(uint id); + bool functionIntVisible(uint id); + /// Set the visible of the function. Returns true if it succeeds, otherwise false. + bool setFunctionFVisible(bool visible, uint id); + bool setFunctionF1Visible(bool visible, uint id); + bool setFunctionF2Visible(bool visible, uint id); + bool setFunctionIntVisible(bool visible, uint id); + + /// Returns the function expression, or an empty string if the function couldn't be found + QString functionStr(uint id); + /// Returns the complete function string including the extensions of a function, or an empty string if the function couldn't be found + + /// Get the color of a graph + QColor functionFColor(uint id); + QColor functionF1Color(uint id); + QColor functionF2Color(uint id); + QColor functionIntColor(uint id); + /// Set the color of a graph. Returns true if it succeeds, otherwise false. + bool setFunctionFColor(const QColor &color, uint id); + bool setFunctionF1Color(const QColor &color, uint id); + bool setFunctionF2Color(const QColor &color, uint id); + bool setFunctionIntColor(const QColor &color, uint id); + + /// Get the line width of a graph + int functionFLineWidth(uint id); + int functionF1LineWidth(uint id); + int functionF2LineWidth(uint id); + int functionIntLineWidth(uint id); + /// Set the line width of a graph. Returns true if it succeeds, otherwise false. + bool setFunctionFLineWidth(int linewidth, uint id); + bool setFunctionF1LineWidth(int linewidth, uint id); + bool setFunctionF2LineWidth(int linewidth, uint id); + bool setFunctionIntLineWidth(int linewidth, uint id); + + /// Returns the function's parameter list + QStringList functionParameterList(uint id); + bool functionAddParameter(const QString &new_parameter, uint id); + bool functionRemoveParameter(const QString &remove_parameter, uint id); + int addFunction(const QString &f_str); + bool addFunction(const QString &extstr, bool f_mode, bool f1_mode, bool f2_mode, bool integral_mode, bool integral_use_precision, int linewidth, int f1_linewidth, int f2_linewidth, int integral_linewidth, const QString &str_dmin, const QString &str_dmax, const QString &str_startx, const QString &str_starty, double integral_precision, QRgb color, QRgb f1_color, QRgb f2_color, QRgb integral_color, QStringList str_parameter, int use_slider); + bool setFunctionExpression(const QString &f_str, uint id); + + /// Get the min and max value of a graph + QString functionMinValue(uint id); + QString functionMaxValue(uint id); + /// Set the min and max values of a graph. Returns true if it succeeds, otherwise false. + bool setFunctionMinValue(const QString &min, uint id); + bool setFunctionMaxValue(const QString &max, uint id); + + /// Get the startx and starty value of a graph + QString functionStartXValue(uint id); + QString functionStartYValue(uint id); + /// Set the startx and starty values of a graph. Returns true if it succeeds, otherwise false. + bool setFunctionStartXValue(const QString &x, uint id); + bool setFunctionStartYValue(const QString &y, uint id); +private: + + /// finds a free function name + void findFunctionName(QString &, int const, int const); + /// indicates if the widget is changed + bool &m_modified; +}; + +#endif //xparser_included |