mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-05-01 01:25:56 +01:00
Plot: code cleaning
This commit is contained in:
parent
98567eb4d6
commit
62d395e8e2
18
lib/Plot.cpp
18
lib/Plot.cpp
@ -113,13 +113,13 @@ PlotData::PlotData(const XYStatData &data, const Index i, const Index j)
|
|||||||
|
|
||||||
// PlotFunction constructor ////////////////////////////////////////////////////
|
// PlotFunction constructor ////////////////////////////////////////////////////
|
||||||
PlotFunction::PlotFunction(const DoubleFunction &function, const double xMin,
|
PlotFunction::PlotFunction(const DoubleFunction &function, const double xMin,
|
||||||
const double xMax, const unsigned int nSample)
|
const double xMax, const unsigned int nPoint)
|
||||||
{
|
{
|
||||||
DMat d(nSample, 2);
|
DMat d(nPoint, 2);
|
||||||
string tmpFileName;
|
string tmpFileName;
|
||||||
double dx = (xMax - xMin)/static_cast<double>(nSample - 1);
|
double dx = (xMax - xMin)/static_cast<double>(nPoint - 1);
|
||||||
|
|
||||||
for (Index i = 0; i < nSample; ++i)
|
for (Index i = 0; i < nPoint; ++i)
|
||||||
{
|
{
|
||||||
d(i, 0) = xMin + i*dx;
|
d(i, 0) = xMin + i*dx;
|
||||||
d(i, 1) = function(d(i, 0));
|
d(i, 1) = function(d(i, 0));
|
||||||
@ -278,14 +278,14 @@ void Plot::getProgramPath(void)
|
|||||||
char *path;
|
char *path;
|
||||||
static char buf[MAX_PATH_LENGTH];
|
static char buf[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
/* Trivial case: try in CWD */
|
// trivial case: try in CWD
|
||||||
sprintf(buf,"./%s", gnuplotBin_.c_str()) ;
|
sprintf(buf,"./%s", gnuplotBin_.c_str()) ;
|
||||||
if (access(buf, X_OK) == 0)
|
if (access(buf, X_OK) == 0)
|
||||||
{
|
{
|
||||||
sprintf(buf,".");
|
sprintf(buf,".");
|
||||||
gnuplotPath_ = buf;
|
gnuplotPath_ = buf;
|
||||||
}
|
}
|
||||||
/* Try out in all paths given in the PATH variable */
|
// try out in all paths given in the PATH variable
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
@ -305,7 +305,7 @@ void Plot::getProgramPath(void)
|
|||||||
strcpy(buf + lg, gnuplotBin_.c_str());
|
strcpy(buf + lg, gnuplotBin_.c_str());
|
||||||
if (access(buf, X_OK) == 0)
|
if (access(buf, X_OK) == 0)
|
||||||
{
|
{
|
||||||
/* Found it! */
|
// found it!
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
@ -317,12 +317,12 @@ void Plot::getProgramPath(void)
|
|||||||
{
|
{
|
||||||
LATAN_ERROR(System, "PATH variable not set");
|
LATAN_ERROR(System, "PATH variable not set");
|
||||||
}
|
}
|
||||||
/* If the buffer is still empty, the command was not found */
|
// if the buffer is still empty, the command was not found
|
||||||
if (buf[0] == 0)
|
if (buf[0] == 0)
|
||||||
{
|
{
|
||||||
LATAN_ERROR(System, "cannot find gnuplot in $PATH");
|
LATAN_ERROR(System, "cannot find gnuplot in $PATH");
|
||||||
}
|
}
|
||||||
/* Otherwise truncate the command name to yield path only */
|
// otherwise truncate the command name to yield path only
|
||||||
lg = (int)(strlen(buf) - 1);
|
lg = (int)(strlen(buf) - 1);
|
||||||
while (buf[lg]!='/')
|
while (buf[lg]!='/')
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ class PlotFunction: public PlotObject
|
|||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
PlotFunction(const DoubleFunction &function, const double xMin,
|
PlotFunction(const DoubleFunction &function, const double xMin,
|
||||||
const double xMax, const unsigned int nSample = 1000);
|
const double xMax, const unsigned int nPoint = 1000);
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~PlotFunction(void) = default;
|
virtual ~PlotFunction(void) = default;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user