Commit 7ee1e78d authored by Fredrik Edemar's avatar Fredrik Edemar

* Prefer initializion to assignment in constructors, because it's faster and...

* Prefer initializion to assignment in constructors, because it's faster and cleaner than assigning members in the constructor's body.
* Don't freeze when calculating negative numbers with the function "log".
* Thanks to Frerich Raabe pointing out that "const QString sessionId" in MainDlg's constructor should be "const QString &sessionId".
* Get rid of some warnings in View.cpp
* I don't know why "private:" was uncommented in parser.h, but that is fixed now.


CCMAIL:kdmoeller@foni.net
CCMAIL:bmlmessmer@web.de
raabe@kde.org

svn path=/trunk/kdeedu/kmplot/; revision=319798
parent 3a9b8dcc
......@@ -18,7 +18,6 @@ TODO
TODO for KDE 3.3
=========================
* Draw tangents in trace mode (pipesmoker)
* Import parameter values from different file format(.csv, KSpread, OpenOffice) via Koffice (see kde-edu/kig)
* Printing (pipesmoker)
- different paper sizes
......@@ -26,6 +25,7 @@ TODO for KDE 3.3
IN PROGRESS
=========================
* Configure Dialog for global Settings / save as default Checkboxes (Started)
* Import parameter values from different file format(.csv, KSpread, OpenOffice) via Koffice (see kde-edu/kig)
DONE
......
......@@ -45,9 +45,8 @@
#define Inherited FktDlgData
FktDlg::FktDlg( QWidget* parent, XParser* parser ) : Inherited( parent, "editPlots" )
FktDlg::FktDlg( QWidget* parent, XParser* parser ) : Inherited( parent, "editPlots" ), m_parser(parser)
{
m_parser = parser;
}
FktDlg::~FktDlg()
......
......@@ -58,7 +58,7 @@
bool MainDlg::oldfileversion;
MainDlg::MainDlg( const QString sessionId, KCmdLineArgs* args, const char* name ) : KMainWindow( 0, name ), m_recentFiles( 0 )
MainDlg::MainDlg( const QString &sessionId, KCmdLineArgs* args, const char* name ) : KMainWindow( 0, name ), m_sessionId(sessionId ), m_recentFiles( 0 )
{
fdlg = 0;
m_popupmenu = new KPopupMenu(this);
......@@ -72,9 +72,8 @@ MainDlg::MainDlg( const QString sessionId, KCmdLineArgs* args, const char* name
setupStatusBar();
setupActions();
loadConstants();
m_sessionId = sessionId;
if (args -> count() > 0)
{
m_filename = args -> url( 0 ).url(-1);
......
......@@ -74,7 +74,7 @@ class MainDlg : public KMainWindow
* @param args containing a filename to be plot on startup.
* @param name
*/
MainDlg( const QString sessionId, KCmdLineArgs* args, const char* name = NULL );
MainDlg( const QString &sessionId, KCmdLineArgs* args, const char* name = NULL );
/// Cleaning up a bit.
virtual ~MainDlg();
/// This class needs access to private members, too.
......
......@@ -84,7 +84,7 @@ void KmPlotProgress::increase()
* View implementation
*/
View::View(bool & mo, KPopupMenu *m, QWidget* parent, const char* name ) : QWidget( parent, name , WStaticContents ), buffer( width(), height() ), m_modified(mo)
View::View(bool & mo, KPopupMenu *p, QWidget* parent, const char* name ) : QWidget( parent, name , WStaticContents ), buffer( width(), height() ), m_popupmenu(p), m_modified(mo)
{
m_parser = new XParser( 10, 200, 20 );
......@@ -105,7 +105,6 @@ View::View(bool & mo, KPopupMenu *m, QWidget* parent, const char* name ) : QWidg
QToolTip::add( sliders[ number ]->slider, i18n( "Slider no. %1" ).arg( number ) );
}
updateSliders();
m_popupmenu = m;
m_popupmenushown = 0;
m_popupmenu->insertTitle( "",10);
zoom_mode = 0;
......@@ -1109,11 +1108,13 @@ void View::progressbar_clicked()
void View::findMinMaxValue(int ix, char p_mode, bool minimum, double &dmin, double &dmax, QString &str_parameter)
{
double dx, x, y, result_x, result_y;
bool start = false;
double x, y;
double result_x = 0;
double result_y = 0;
bool start = true;
if(ix==-1 || ix>=m_parser->ufanz) return ; // ungltiger Index
dx = stepWidth;
double dx = stepWidth;
// TODO: parameter sliders
int i=0;
......@@ -1186,11 +1187,11 @@ void View::findMinMaxValue(int ix, char p_mode, bool minimum, double &dmin, doub
if ( y>=ymin &&y<=ymax)
{
if ( !start)
if ( start)
{
result_x = x;
result_y = y;
start=true;
start=false;
}
else if ( minimum &&y <=result_y)
{
......
......@@ -58,7 +58,7 @@
#include "kparametereditor.h"
EditFunction::EditFunction( XParser* parser, QWidget* parent, const char* name ) :
KDialogBase( IconList, "Caption", Help|Ok|Cancel, Ok, parent, 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 );
......@@ -66,7 +66,6 @@ EditFunction::EditFunction( XParser* parser, QWidget* parent, const char* name )
editderivativespage = new EditDerivativesPage( page1 );
QVBox *page2 = addVBoxPage( i18n("Antiderivative"), i18n( "Antiderivative" ), SmallIcon( "anti_func", 32 ) );
editantiderivativepage = new EditAntiderivativePage( page2 );
m_parser = parser;
for( int number = 0; number < SLIDER_COUNT; number++ )
{
editfunctionpage->listOfSliders->insertItem( QString( "Slider no. %1" ).arg( number ) );
......
......@@ -47,9 +47,8 @@ KConstantEditor::KConstantEditor(QWidget *parent, const char *name)
}
KConstantEditor::KConstantEditor(View *v, QWidget *parent, const char *name)
: QConstantEditor(parent,name)
: QConstantEditor(parent,name), m_view(v)
{
m_view = v;
QString str_value;
QValueVector<Constant>::iterator it;
for(it = m_view->parser()->constant.begin(); it!= m_view->parser()->constant.end() ;it++)
......@@ -101,7 +100,7 @@ void KConstantEditor::cmdDelete_clicked()
{
if ( m_view->parser()->getfkt( index, fname, fstr ) == -1 ) continue;
str = m_view->parser()->fktext[ index ].extstr ;
for (int i=str.find(')'); i<str.length() && !stop;i++)
for (int i=str.find(')'); (uint)i<str.length() && !stop;i++)
if ( str.at(i) == constant )
stop = true;
}
......
......@@ -42,9 +42,8 @@
#include "View.h"
KEditParametric::KEditParametric( XParser* parser, QWidget* parent, const char* name ) :
QEditParametric( parent, name )
QEditParametric( parent, name ), m_parser(parser)
{
m_parser = parser;
}
void KEditParametric::initDialog( int x_index, int y_index )
......
......@@ -43,9 +43,8 @@
#include "View.h"
KEditPolar::KEditPolar( XParser* parser, QWidget* parent, const char* name ) :
QEditPolar( parent, name )
QEditPolar( parent, name ),m_parser(parser)
{
m_parser = parser;
}
void KEditPolar::initDialog( int index )
......
......@@ -39,9 +39,8 @@ KMinMax::KMinMax(QWidget *parent, const char *name)
KMinMax::KMinMax(View *v, QWidget *parent, const char *name)
: QMinMax(parent, name)
: QMinMax(parent, name), m_view(v)
{
m_view=v;
m_mode=-1;
connect( cmdClose, SIGNAL( clicked() ), this, SLOT( close() ));
connect( cmdFind, SIGNAL( clicked() ), this, SLOT( cmdFind_clicked() ));
......
......@@ -42,10 +42,8 @@ KParameterEditor::KParameterEditor(QWidget *parent, const char *name)
}
KParameterEditor::KParameterEditor(XParser *m, QStringList *l, QWidget *parent, const char *name)
: QParameterEditor(parent,name, true, Qt::WDestructiveClose)
: QParameterEditor(parent,name, true, Qt::WDestructiveClose), m_parameter(l), m_parser(m)
{
m_parameter = l;
m_parser = m;
for ( QStringList::Iterator it = m_parameter->begin(); it != m_parameter->end(); ++it )
list->insertItem(*it);
list->sort();
......@@ -63,7 +61,7 @@ KParameterEditor::KParameterEditor(XParser *m, QStringList *l, QWidget *parent,
KParameterEditor::~KParameterEditor()
{
m_parameter->clear();
for (int i = 0; i <= list->count();i++)
for (int i = 0; (uint)i <= list->count();i++)
{
if ( !list->text(i).isEmpty() )
m_parameter->append(list->text(i));
......
......@@ -52,7 +52,7 @@ Parser::Mfkt Parser::mfkttab[ FANZ ]=
{"sign", sign}, // Signum
{"sech", sech}, // Secans hyperbolicus
{"sec", sec}, // Secans
{"log", log10}, // Logarithm base 10
{"log", llog}, // Logarithm base 10
{"ln", ln}, // Logarithm base e
{"exp", exp}, // Exponential function base e
{"coth", coth}, // Co-Tangens hyperbolicus
......@@ -726,11 +726,17 @@ int Parser::errmsg()
return err;
}
double ln(double x)
{ if (x>0)
return log(x);
}
double llog(double x)
{ if (x>0)
return log10(x);
}
double sign(double x)
{ if(x<0.) return -1.;
else if(x>0.) return 1.;
......@@ -840,4 +846,4 @@ double arcsin(double x)
double arctan(double x)
{ return atan(x)* 1/Parser::anglemode();
}
}
\ No newline at end of file
......@@ -62,6 +62,7 @@
//@{
/** Predefined mathematical function. */
double ln(double x);
double llog(double x);
double sign(double x);
double sqr(double x);
double arsinh(double x);
......@@ -208,9 +209,7 @@ protected:
};
static Mfkt mfkttab[FANZ];
//private:
public:
private:
void ps_init(int, int, int),
heir1(),
heir2(),
......
......@@ -23,7 +23,7 @@ void QConstantEditor::cmdDelete_clicked()
}
void QConstantEditor::varlist_clicked( QListViewItem * item )
void QConstantEditor::varlist_clicked( QListViewItem * )
{
}
......
......@@ -183,20 +183,21 @@ double XParser::a2fkt( int ix, double x, double h )
char XParser::findFunctionName()
{
char function_name ='f';
for (bool ok=true; function_name< 'z'+1 ;function_name++)
for (bool ok=true; function_name< 'x';function_name++)
{
for ( int i = 0; i < ufanz; i++ )
{
if (fktext[ i ].extstr.at(0) == function_name )
if (fktext[ i ].extstr.at(1) == '(' )
if (fktext[ i ].extstr.at(0) == function_name ) //check if
if (fktext[ i ].extstr.at(1) == '(' ) //and the function name is one letter
ok = false;
}
if ( ok)
if ( ok) //free name
{
return function_name;
}
ok = true;
}
return 'e'; //this should never happen, because the limit of 10 functions
}
void XParser::fixFunctionName( QString &str)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment