Commit 7402f5db authored by David Saxton's avatar David Saxton

Alias pi symbol (unicode 0x3c0) to pi constant.

svn path=/trunk/KDE/kdeedu/kmplot/; revision=523545
parent 61b2ab27
......@@ -439,15 +439,15 @@ void CDiagr::drawLabels(QPainter* pDC)
if(fabs(ex-M_PI/2.)<1e-3)
{
if(n==-1 || n==1)
s+="pi/2";//s+=QChar(960)+QString("/2");
s+=QChar(960)+QString("/2");
else if(n%2 == 0)
{
if(n==-2 || n==2)
s+="pi";//s+=QChar(960);
s+=QChar(960);
else
{
s=QString().sprintf("%+d", n/2);
s+="pi";//s+=QChar(960);
s+=QChar(960);
}
}
else
......@@ -473,15 +473,15 @@ void CDiagr::drawLabels(QPainter* pDC)
else if(fabs(ex-M_PI/3.)<1e-3)
{
if(n==-1 || n==1)
s+="pi/3";//s+=QChar(960)+QString("/3");
s+=QChar(960)+QString("/3");
else if(n%3==0)
{
if(n==-3 || n==3)
s+="pi";//s+=QChar(960);
s+=QChar(960);
else
{
s=QString().sprintf("%+d", n/3);
s+="pi";//s+=QChar(960);
s+=QChar(960);
}
}
else
......@@ -507,15 +507,15 @@ void CDiagr::drawLabels(QPainter* pDC)
else if(fabs(ex-M_PI/4.)<1e-3)
{
if(n==-1 || n==1)
s+="pi/4";//s+=QChar(960)+QString("/4");
s+=QChar(960)+QString("/4");
else if(n%4==0)
{
if(n==-4 || n==4)
s+="pi";//s+=QChar(960);
s+=QChar(960);
else
{
s=QString().sprintf("%+d", n/4);
s+="pi";//s+=QChar(960);
s+=QChar(960);
}
}
else
......@@ -579,15 +579,15 @@ void CDiagr::drawLabels(QPainter* pDC)
if(fabs(ey-M_PI/2.)<1e-3)
{
if(n==-1 || n==1)
s+="pi/2";//s+=QChar(960)+QString("/2");
s+=QChar(960)+QString("/2");
else if(n%2==0)
{
if(n==-2 || n==2)
s+="pi";//s+=QChar(960);
s+=QChar(960);
else
{
s=QString().sprintf("%+d", n/2);
s+="pi";//s+=QChar(960);
s+=QChar(960);
}
}
else
......@@ -600,15 +600,15 @@ void CDiagr::drawLabels(QPainter* pDC)
else if(fabs(ey-M_PI/3.)<1e-3)
{
if(n==-1 || n==1)
s+="pi/3";//s+=QChar(960)+QString("/3");
s+=QChar(960)+QString("/3");
else if(n%3==0)
{
if(n==-3 || n==3)
s+="pi";//s+=QChar(960);
s+=QChar(960);
else
{
s=QString().sprintf("%+d", n/3);
s+="pi";//s+=QChar(960);
s+=QChar(960);
}
}
else
......@@ -621,15 +621,15 @@ void CDiagr::drawLabels(QPainter* pDC)
else if(fabs(ey-M_PI/4.)<1e-3)
{
if(n==-1 || n==1)
s+="pi/4";//s+=QChar(960)+QString("/4");
s+=QChar(960)+QString("/4");
else if(n%4==0)
{
if(n==-4 || n==4)
s+="pi";//s+=QChar(960);
s+=QChar(960);
else
{
s=QString().sprintf("%+d", n/4);
s+="pi";//s+=QChar(960);
s+=QChar(960);
}
}
else
......
......@@ -802,9 +802,9 @@ void Parser::primary()
return;
}
if(match("pi"))
if ( match("pi") || match( QChar(960) ) )
{
addtoken(KONST);
addtoken(KONST);
addwert(M_PI);
return;
}
......@@ -1285,8 +1285,8 @@ void Constants::add( Constant c )
bool Constants::isValidName( QChar name )
{
// special case: handle heaviside step function
if ( name == 'H' )
// special cases: disallow heaviside step function, pi symbol
if ( name == 'H' || name == QChar(960) )
return false;
switch ( name.category() )
......
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