Commit f7f225f9 authored by David Saxton's avatar David Saxton

- For Cartesian plots, use distance to closest point insetad of distance to

  point using the mouse's x-pos for finding the plot under the mouse.
- Use closest plot to click point instead of first plot within required
  distance when finding the plot that was clicked on.

svn path=/trunk/KDE/kdeedu/kmplot/; revision=526458
parent b2a4006f
This diff is collapsed.
......@@ -84,9 +84,9 @@ public:
/// @see getSettings
void init();
/// Finding the minimum or maximum value
void findMinMaxValue(Function *, char, bool, double &, double &,const QString &);
void findMinMaxValue(Function *, Function::PMode, bool, double &, double &,const QString &);
/// get a y-value from a x-value
void getYValue(Function * , char, double , double &,const QString &);
void getYValue(Function * , Function::PMode, double , double &,const QString &);
/// draw and calculate the area between the graph and the x-axis.
void areaUnderGraph(Function *, Function::PMode, double &, double &, const QString &, QPainter* );
/// the calculation was cancelled by the user
......@@ -204,16 +204,15 @@ private:
*/
void getPlotUnderMouse();
/**
* Finds the closest point to \p real_x and \p real_y to the given polar or
* parametric function.
* Finds the closest point to \p real_x and \p real_y to the given function.
* \return the parametization (angle or t) that gives the closest point.
*/
double getClosestPoint( double real_x, double real_y, Function * function );
double getClosestPoint( double real_x, double real_y, Function * function, Function::PMode mode );
/**
* Calculates the pixel distance from \p real_x and \p real_y to the display
* point of the given polar or parametric parametric function at \p x.
* point of the given function at \p x.
*/
double pixelDistance( double real_x, double real_y, Function * function, double x );
double pixelDistance( double real_x, double real_y, Function * function, Function::PMode mode, double x );
/**
* @return a string for displaying the x or y coordinate in the statusbar.
* \param delta is the amount by which the value varies over one pixel in
......@@ -221,6 +220,11 @@ private:
* moving the cursor shows a nice change in the string.
*/
QString posToString( double x, double delta ) const;
/**
* Convenience function for calculating the value of \p eq using the
* given \p mode (which cannot be Function::Integral).
*/
double value( Equation * eq, Function::PMode mode, double x );
/// for areadrawing when printing
......
......@@ -186,7 +186,7 @@ bool Equation::setFstr( const QString & fstr, bool force )
if ( !XParser::self()->isFstrValid( fstr ) )
{
XParser::self()->parserError( true );
XParser::self()->parserError( false );
// kDebug() << k_funcinfo << "invalid fstr\n";
return false;
}
......@@ -194,7 +194,7 @@ bool Equation::setFstr( const QString & fstr, bool force )
QString prevFstr = m_fstr;
m_fstr = fstr;
XParser::self()->initEquation( this );
if ( XParser::self()->parserError( true ) != Parser::ParseSuccess )
if ( XParser::self()->parserError( false ) != Parser::ParseSuccess )
{
m_fstr = prevFstr;
XParser::self()->initEquation( this );
......@@ -240,6 +240,9 @@ Function::Function( Type type )
integral_precision = Settings::stepWidth();
use_slider = -1;
startx.updateExpression( "0" );
starty.updateExpression( "0" );
// min/max stuff
dmin.updateExpression( QString("-")+QChar(960) );
dmax.updateExpression( QChar(960) );
......
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