Skip to content

Commit

Permalink
Re #11422 Improved comment style consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew D Jones authored and Matthew D Jones committed Aug 6, 2015
1 parent a227c27 commit c267193
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ class QWT_EXPORT MantidQwtPowerScaleEngine: public QwtScaleEngine
virtual QwtScaleTransformation *transformation() const;

protected:
QwtDoubleInterval log10(const QwtDoubleInterval&) const;
QwtDoubleInterval pow10(const QwtDoubleInterval&) const;
QwtDoubleInterval Power(const QwtDoubleInterval&) const;
QwtDoubleInterval Root(const QwtDoubleInterval&) const;

private:

int nth_power = 2; // TODO this should be user input from GUI
// TODO this should be user input from GUI
int nth_power = 2;

QwtDoubleInterval align(const QwtDoubleInterval&,
double stepSize) const;
Expand Down
85 changes: 45 additions & 40 deletions Code/Mantid/MantidQt/API/src/MantidQwtPowerScaleEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,39 @@
#include "MantidQwtScaleTransformation.h"
#include "MantidQwtPowerScaleEngine.h"

/*!
Return a transformation, for power scales
*/
/*
* Return a transformation, for power scales
*/
MantidQwtScaleTransformation *MantidQwtPowerScaleEngine::transformation() const
{
return new MantidQwtScaleTransformation(MantidQwtScaleTransformation::Power);
}

/*!
Align and divide an interval
\param maxNumSteps Max. number of steps
\param x1 First limit of the interval (In/Out)
\param x2 Second limit of the interval (In/Out)
\param stepSize Step size (Out)
\sa QwtScaleEngine::setAttribute()
*/
/*
* Align and divide an interval
*
* @param maxNumSteps Max. number of steps
* @param x1 First limit of the interval (In/Out)
* @param x2 Second limit of the interval (In/Out)
* @param stepSize Step size (Out)
*
* @sa QwtScaleEngine::setAttribute()
*/
void MantidQwtPowerScaleEngine::autoScale(int maxNumSteps,
double &x1, double &x2, double &stepSize) const
{
const double one_over_n = 1.0/nth_power

if ( x1 > x2 )
qSwap(x1, x2);

QwtDoubleInterval interval(x1 / pow(10.0, lowerMargin()),
x2 * pow(10.0, upperMargin()) );
QwtDoubleInterval interval(x1 / pow(lowerMargin(), one_over_n),
x2 * pow(upperMargin(), one_over_n) );

double logRef = 1.0;

// TODO where are LOG_MIN and LOG_MAX from?
// What is their role?
if (reference() > LOG_MIN / 2)
logRef = qwtMin(reference(), LOG_MAX / 2);

Expand Down Expand Up @@ -65,18 +70,18 @@ void MantidQwtPowerScaleEngine::autoScale(int maxNumSteps,
}
}

/*!
\brief Calculate a scale division
\param x1 First interval limit
\param x2 Second interval limit
\param maxMajSteps Maximum for the number of major steps
\param maxMinSteps Maximum number of minor steps
\param stepSize Step size. If stepSize == 0, the scaleEngine
calculates one.
\sa QwtScaleEngine::stepSize(), QwtLog10ScaleEngine::subDivide()
*/
/*
* Calculate a scale division
*
* @param x1 First interval limit
* @param x2 Second interval limit
* @param maxMajSteps Maximum for the number of major steps
* @param maxMinSteps Maximum number of minor steps
* @param stepSize Step size. If stepSize == 0, the scaleEngine
* calculates one.
*
* @sa QwtScaleEngine::stepSize(), QwtLog10ScaleEngine::subDivide()
*/
QwtScaleDiv MantidQwtPowerScaleEngine::divideScale(double x1, double x2,
int maxMajSteps, int maxMinSteps, double stepSize) const
{
Expand Down Expand Up @@ -163,7 +168,7 @@ QwtValueList MantidQwtPowerScaleEngine::buildMajorTicks(
ticks += interval.minValue();

for (int i = 1; i < numTicks; i++)
ticks += exp(lxmin + double(i) * lstep);
ticks += exp(lxmin + double(i) * lstep);

ticks += interval.maxValue();

Expand All @@ -177,7 +182,7 @@ QwtValueList MantidQwtPowerScaleEngine::buildMinorTicks(
if (stepSize < 1.1) // major step width is one decade
{
if ( maxMinSteps < 1 )
return QwtValueList();
return QwtValueList();

int k0, kstep, kmax;

Expand Down Expand Up @@ -271,31 +276,31 @@ QwtValueList MantidQwtPowerScaleEngine::buildMinorTicks(
QwtDoubleInterval MantidQwtPowerScaleEngine::align(
const QwtDoubleInterval &interval, double stepSize) const
{
const QwtDoubleInterval intv = Power(interval);
const QwtDoubleInterval intv = Power(interval);

const double x1 = QwtScaleArithmetic::floorEps(intv.minValue(), stepSize);
const double x2 = QwtScaleArithmetic::ceilEps(intv.maxValue(), stepSize);
const double x1 = QwtScaleArithmetic::floorEps(intv.minValue(), stepSize);
const double x2 = QwtScaleArithmetic::ceilEps(intv.maxValue(), stepSize);

return pow10(QwtDoubleInterval(x1, x2));
return Root(QwtDoubleInterval(x1, x2));
}

/*
* Return the interval [nth_Power(interval.minValue(), nth_Power(interval.maxValue]
* Return the interval [nth_power(interval.minValue(), nth_power(interval.maxValue]
*/
QwtDoubleInterval MantidQwtPowerScaleEngine::Power(
const QwtDoubleInterval &interval) const
{
return QwtDoubleInterval(pow(interval.minValue(), nth_power),
pow(interval.maxValue(), nth_power));
return QwtDoubleInterval(pow(interval.minValue(), nth_power),
pow(interval.maxValue(), nth_power));
}

/*
* Return the interval [nth_root(interval.minValue(), nth_root(interval.maxValue]
*/
QwtDoubleInterval MantidQwtPowerScaleEngine::pow10(
QwtDoubleInterval MantidQwtPowerScaleEngine::Root(
const QwtDoubleInterval &interval) const
{
const double nth_root = 1.0/nth_power
return QwtDoubleInterval(pow(interval.minValue(), nth_root),
pow(interval.maxValue(), nth_root));
const double one_over_n = 1.0/nth_power
return QwtDoubleInterval(pow(interval.minValue(), one_over_n),
pow(interval.maxValue(), one_over_n));
}

0 comments on commit c267193

Please sign in to comment.