scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Differentiation Class Reference

#include <Differentiation.h>

Inheritance diagram for Differentiation:
[legend]
Collaboration diagram for Differentiation:
[legend]

Public Member Functions

 Differentiation (ApplicationWindow *parent, Graph *g)
 
 Differentiation (ApplicationWindow *parent, Graph *g, const QString &curveTitle)
 
 Differentiation (ApplicationWindow *parent, Graph *g, const QString &curveTitle, double start, double end)
 
virtual bool run ()
 Actually does the job. Should be reimplemented in derived classes. More...
 
virtual void setDataCurve (int curve, double start, double end)
 
bool setDataFromCurve (const QString &curveTitle, Graph *g=0)
 
bool setDataFromCurve (const QString &curveTitle, double from, double to, Graph *g=0)
 
void setInterval (double from, double to)
 Changes the data range if the source curve was already assigned. Provided for convenience. More...
 
void setTolerance (double eps)
 Sets the tolerance used by the GSL routines. More...
 
void setColor (QColor colorId)
 Sets the color of the output fit curve. More...
 
void setColor (const QString &colorName)
 Sets the color of the output fit curve. Provided for convenience. To be used in scripts only! More...
 
void setOutputPoints (int points)
 Sets the number of points in the output curve. More...
 
void setOutputPrecision (int digits)
 Sets the precision used for the output. More...
 
void setMaximumIterations (int iter)
 Sets the maximum number of iterations to be performed during an iterative session. More...
 
virtual void showLegend ()
 Adds a new legend to the plot. Calls virtual legendInfo() More...
 
virtual QString legendInfo ()
 Output string added to the plot as a new legend. More...
 
int dataSize ()
 Returns the size of the fitted data set. More...
 
bool error ()
 

Protected Member Functions

virtual bool isDataAcceptable ()
 
QwtPlotCurve * addResultCurve (double *x, double *y)
 Adds the result curve to the target output plot window. Creates a hidden table and frees the input data from memory. More...
 
int curveIndex (const QString &curveTitle, Graph *g)
 Performs checks and returns the index of the source data curve if OK, -1 otherwise. More...
 
virtual QString logInfo ()
 Output string added to the log pannel of the application. More...
 
virtual void calculateOutputData (double *X, double *Y)
 Calculates the data for the output curve and store it in the X an Y vectors. More...
 

Protected Attributes

Graphd_graph
 The graph where the result curve should be displayed. More...
 
Tabled_table
 A table source of data. More...
 
unsigned d_n
 Size of the data arrays. More...
 
double * d_x
 x data set to be analysed More...
 
double * d_y
 y data set to be analysed More...
 
double d_tolerance
 GSL Tolerance, if ever needed... More...
 
int d_points
 Number of result points to de calculated and displayed in the output curve. More...
 
QColor d_curveColor
 Color index of the result curve. More...
 
int d_max_iterations
 Maximum number of iterations per fit. More...
 
QwtPlotCurve * d_curve
 The curve to be analysed. More...
 
int d_prec
 Precision (number of significant digits) used for the results output. More...
 
bool d_init_err
 Error flag telling if something went wrong during the initialization phase. More...
 
double d_from
 Data interval. More...
 
double d_to
 
bool d_sort_data
 Specifies if the filter needs sorted data as input. More...
 
int d_min_points
 Minimum number of data points necessary to perform the operation. More...
 
QString d_explanation
 String explaining the operation in the comment of the result table and in the project explorer. More...
 

Private Member Functions

void init ()
 
void output ()
 Performs the data analysis and takes care of the output. More...
 
int curveData (QwtPlotCurve *c, double start, double end, double **x, double **y)
 Sets x and y to the curve points between start and end. More...
 
int sortedCurveData (QwtPlotCurve *c, double start, double end, double **x, double **y)
 Same as curveData, but sorts the points by their x value. More...
 

Detailed Description

File : Differentiation.h

Project : SciDAVis

Copyright : (C) 2007 by Ion Vasilief Email (use @ for *) : ion_vasilief*yahoo.fr Description : Numerical differentiation of data sets

  • This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
    • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
    • You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *

Definition at line 34 of file Differentiation.h.

Constructor & Destructor Documentation

◆ Differentiation() [1/3]

Differentiation::Differentiation ( ApplicationWindow parent,
Graph g 
)

File : Differentiation.cpp

Project : SciDAVis

Copyright : (C) 2007 by Ion Vasilief Email (use @ for *) : ion_vasilief*yahoo.fr Description : Numerical differentiation of data sets

  • This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *
    • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
    • You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *

Definition at line 36 of file Differentiation.cpp.

37 : Filter(parent, g)
38 {
39  init();
40 }

References init().

Here is the call graph for this function:

◆ Differentiation() [2/3]

Differentiation::Differentiation ( ApplicationWindow parent,
Graph g,
const QString &  curveTitle 
)

Definition at line 42 of file Differentiation.cpp.

43 : Filter(parent, g)
44 {
45  init();
46  setDataFromCurve(curveTitle);
47 }

References init(), and Filter::setDataFromCurve().

Here is the call graph for this function:

◆ Differentiation() [3/3]

Differentiation::Differentiation ( ApplicationWindow parent,
Graph g,
const QString &  curveTitle,
double  start,
double  end 
)

Definition at line 49 of file Differentiation.cpp.

50 : Filter(parent, g)
51 {
52  init();
53  setDataFromCurve(curveTitle, start, end);
54 }

References init(), and Filter::setDataFromCurve().

Here is the call graph for this function:

Member Function Documentation

◆ addResultCurve()

QwtPlotCurve * Filter::addResultCurve ( double *  x,
double *  y 
)
protectedinherited

Adds the result curve to the target output plot window. Creates a hidden table and frees the input data from memory.

Definition at line 301 of file Filter.cpp.

302 {
303  ApplicationWindow *app = (ApplicationWindow *)parent();
304  const QString tableName = app->generateUniqueName(this->objectName());
305  Column *xCol = new Column(tr("1", "filter table x column name"), SciDAVis::Numeric);
306  Column *yCol = new Column(tr("2", "filter table y column name"), SciDAVis::Numeric);
309  for (int i=0; i<d_points; i++)
310  {
311  xCol->setValueAt(i, x[i]);
312  yCol->setValueAt(i, y[i]);
313  }
314  // first set the values, then add the columns to the table, otherwise, we generate too many undo commands
315  Table *t = app->newHiddenTable(tableName, d_explanation + " " + tr("of") + " " + d_curve->title().text(),
316  QList<Column *>() << xCol << yCol);
317 
318  DataCurve *c = new DataCurve(t, tableName + "_" + xCol->name(), tableName + "_" + yCol->name());
319  c->setData(x, y, d_points);
320  c->setPen(QPen(d_curveColor, 1));
322  d_graph->updatePlot();
323 
324  return (QwtPlotCurve*)c;
325 }

References Filter::d_curve, Filter::d_curveColor, Filter::d_explanation, Filter::d_graph, Filter::d_points, ApplicationWindow::generateUniqueName(), Graph::insertPlotItem(), Graph::Line, AbstractAspect::name(), ApplicationWindow::newHiddenTable(), SciDAVis::Numeric, Column::setPlotDesignation(), Column::setValueAt(), Graph::updatePlot(), SciDAVis::X, and SciDAVis::Y.

Referenced by Fit::generateFitCurve(), Filter::output(), and Integration::trapezoid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateOutputData()

virtual void Filter::calculateOutputData ( double *  X,
double *  Y 
)
inlineprotectedvirtualinherited

Calculates the data for the output curve and store it in the X an Y vectors.

Reimplemented in SmoothFilter, Interpolation, and FFTFilter.

Definition at line 118 of file Filter.h.

118 { Q_UNUSED(X) Q_UNUSED(Y) };

Referenced by Filter::output().

Here is the caller graph for this function:

◆ curveData()

int Filter::curveData ( QwtPlotCurve *  c,
double  start,
double  end,
double **  x,
double **  y 
)
privateinherited

Sets x and y to the curve points between start and end.

Returns
the number of points within range == size of x and y arrays. Memory will be allocated with new double[].

Definition at line 275 of file Filter.cpp.

276 {
277  if (!c || c->rtti() != QwtPlotItem::Rtti_PlotCurve)
278  return 0;
279 
280  int datasize = c->dataSize();
281  int i_start = 0, i_end = c->dataSize();
282  for (i_start = 0; i_start < datasize; i_start++)
283  if (c->x(i_start) >= start)
284  break;
285  for (i_end = datasize-1; i_end >= 0; i_end--)
286  if (c->x(i_end) <= end)
287  break;
288 
289  int n = i_end - i_start + 1;
290  // TODO refactor caller code to make this mroe RAII.
291  (*x) = new double[n];
292  (*y) = new double[n];
293 
294  for (int j = 0, i = i_start; i <= i_end; i++, j++) {
295  (*x)[j] = c->x(i);
296  (*y)[j] = c->y(i);
297  }
298  return n;
299 }

Referenced by Filter::setDataCurve().

Here is the caller graph for this function:

◆ curveIndex()

int Filter::curveIndex ( const QString &  curveTitle,
Graph g 
)
protectedinherited

Performs checks and returns the index of the source data curve if OK, -1 otherwise.

Definition at line 129 of file Filter.cpp.

130 {
131  if (curveTitle.isEmpty())
132  {
133  QMessageBox::critical((ApplicationWindow *)parent(), tr("Filter Error"),
134  tr("Please enter a valid curve name!"));
135  d_init_err = true;
136  return -1;
137  }
138 
139  if (g)
140  d_graph = g;
141 
142  if (!d_graph)
143  {
144  d_init_err = true;
145  return -1;
146  }
147 
148  return d_graph->curveIndex(curveTitle);
149 }

References Graph::curveIndex(), Filter::d_graph, and Filter::d_init_err.

Referenced by Filter::setDataFromCurve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dataSize()

int Filter::dataSize ( )
inlineinherited

Returns the size of the fitted data set.

Definition at line 85 of file Filter.h.

85 {return d_n;};

References Filter::d_n.

◆ error()

bool Filter::error ( )
inlineinherited

Definition at line 87 of file Filter.h.

87 {return d_init_err;};

References Filter::d_init_err.

Referenced by Fit::evaluate_df_helper(), Fit::fit(), SmoothFilter::savitzkyGolayCoefficients(), Fit::setYErrorSource(), SmoothFilter::smoothModifiedSavGol(), and SmoothFilter::smoothSavGol().

Here is the caller graph for this function:

◆ init()

void Differentiation::init ( )
private

Definition at line 56 of file Differentiation.cpp.

57 {
58  setObjectName(tr("Derivative"));
59  d_min_points = 4;
60 }

References Filter::d_min_points.

Referenced by Differentiation().

Here is the caller graph for this function:

◆ isDataAcceptable()

bool Filter::isDataAcceptable ( )
protectedvirtualinherited

Reimplemented in Interpolation, and Integration.

Definition at line 120 of file Filter.cpp.

120  {
121  if (d_n < unsigned(d_min_points)) {
122  QMessageBox::critical((ApplicationWindow *)parent(), tr("SciDAVis") + " - " + tr("Error"),
123  tr("You need at least %1 points in order to perform this operation!").arg(d_min_points));
124  return false;
125  }
126  return true;
127 }

References Filter::d_min_points, and Filter::d_n.

Referenced by Integration::isDataAcceptable(), Interpolation::isDataAcceptable(), and Filter::setDataCurve().

Here is the caller graph for this function:

◆ legendInfo()

virtual QString Filter::legendInfo ( )
inlinevirtualinherited

Output string added to the plot as a new legend.

Reimplemented in PolynomialFit, and Fit.

Definition at line 82 of file Filter.h.

82 {return QString();};

Referenced by Filter::showLegend().

Here is the caller graph for this function:

◆ logInfo()

virtual QString Filter::logInfo ( )
inlineprotectedvirtualinherited

Output string added to the log pannel of the application.

Reimplemented in Integration.

Definition at line 112 of file Filter.h.

112 {return QString();};

Referenced by Filter::run().

Here is the caller graph for this function:

◆ output()

void Differentiation::output ( )
privatevirtual

Performs the data analysis and takes care of the output.

Reimplemented from Filter.

Definition at line 62 of file Differentiation.cpp.

63 {
64  Column *xCol = new Column(tr("1", "differention table x column name"), SciDAVis::Numeric);
65  Column *yCol = new Column(tr("2", "differention table y column name"), SciDAVis::Numeric);
68  for (unsigned i = 1; i < d_n-1; i++) {
69  xCol->setValueAt(i-1, d_x[i]);
70  yCol->setValueAt(i-1, 0.5*((d_y[i+1]-d_y[i])/(d_x[i+1]-d_x[i]) + (d_y[i]-d_y[i-1])/(d_x[i]-d_x[i-1])));
71  }
72 
73  ApplicationWindow *app = (ApplicationWindow *)parent();
74  QString tableName = app->generateUniqueName(objectName());
75  QString curveTitle = d_curve->title().text();
76  Table *t = app->newHiddenTable(tableName, tr("Derivative") + " " + tr("of","Derivative of") + " " + curveTitle, QList<Column *>() << xCol << yCol);
77  MultiLayer *ml = app->newGraph(tr("Plot")+tr("Derivative"));
78  ml->activeGraph()->insertCurve(t, tableName + "_" + yCol->name(), 0);
79  Legend *l = ml->activeGraph()->legend();
80  l->setText("\\c{1}" + tr("Derivative") + " " + tr("of","Derivative of") + " " + curveTitle);
81 }

References MultiLayer::activeGraph(), Filter::d_curve, Filter::d_n, Filter::d_x, Filter::d_y, ApplicationWindow::generateUniqueName(), Graph::insertCurve(), Graph::legend(), AbstractAspect::name(), ApplicationWindow::newGraph(), ApplicationWindow::newHiddenTable(), SciDAVis::Numeric, Column::setPlotDesignation(), Legend::setText(), Column::setValueAt(), SciDAVis::X, and SciDAVis::Y.

Here is the call graph for this function:

◆ run()

bool Filter::run ( )
virtualinherited

Actually does the job. Should be reimplemented in derived classes.

Definition at line 208 of file Filter.cpp.

209 {
210  if (d_init_err)
211  return false;
212 
213 // if (d_n < 0)
214 // {
215 // QMessageBox::critical((ApplicationWindow *)parent(), tr("SciDAVis") + " - " + tr("Error"),
216 // tr("You didn't specify a valid data set for this operation!"));
217 // return false;
218 // }
219 
220  QApplication::setOverrideCursor(Qt::WaitCursor);
221 
222  output();//data analysis and output
223  ((ApplicationWindow *)parent())->updateLog(logInfo());
224 
225  QApplication::restoreOverrideCursor();
226  return true;
227 }

References Filter::d_init_err, Filter::logInfo(), and Filter::output().

Referenced by FFTDialog::accept(), IntDialog::accept(), ApplicationWindow::analyzeCurve(), ApplicationWindow::autoCorrelate(), ApplicationWindow::convolute(), ApplicationWindow::correlate(), ApplicationWindow::deconvolute(), FilterDialog::filter(), InterpolationDialog::interpolate(), and SmoothCurveDialog::smooth().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColor() [1/2]

void Filter::setColor ( const QString &  colorName)
inherited

Sets the color of the output fit curve. Provided for convenience. To be used in scripts only!

Definition at line 178 of file Filter.cpp.

179 {
180  QColor c = QColor(COLORVALUE(colorName));
181  if (colorName == "green")
182  c = QColor(Qt::green);
183  else if (colorName == "darkYellow")
184  c = QColor(Qt::darkYellow);
186  {
187  QMessageBox::critical((ApplicationWindow *)parent(), tr("Color Name Error"),
188  tr("The color name '%1' is not valid, a default color (red) will be used instead!").arg(colorName));
190  return;
191  }
192 
193  d_curveColor = c;
194 }

References ColorButton::color(), COLORVALUE(), Filter::d_curveColor, and ColorButton::isValidColor().

Here is the call graph for this function:

◆ setColor() [2/2]

void Filter::setColor ( QColor  colorId)
inlineinherited

Sets the color of the output fit curve.

Definition at line 64 of file Filter.h.

64 {d_curveColor = colorId;};

References Filter::d_curveColor.

Referenced by FitDialog::accept(), FilterDialog::filter(), ExpDecayDialog::fit(), PolynomFitDialog::fit(), InterpolationDialog::interpolate(), and SmoothCurveDialog::smooth().

Here is the caller graph for this function:

◆ setDataCurve()

void Filter::setDataCurve ( int  curve,
double  start,
double  end 
)
virtualinherited

Reimplemented in Fit.

Definition at line 90 of file Filter.cpp.

91 {
92  if (start > end) qSwap(start, end);
93 
94  if (d_n > 0)
95  {//delete previousely allocated memory
96  delete[] d_x;
97  delete[] d_y;
98  }
99 
100  d_init_err = false;
101  d_curve = d_graph->curve(curve);
102  if (d_sort_data)
103  d_n = sortedCurveData(d_curve, start, end, &d_x, &d_y);
104  else
105  d_n = curveData(d_curve, start, end, &d_x, &d_y);
106 
107  if (!isDataAcceptable()) {
108  d_init_err = true;
109  return;
110  }
111 
112  // ensure range is within data range
113  if (d_n>0)
114  {
115  d_from = max(start, *min_element(d_x,d_x+d_n));
116  d_to = min(end, *max_element(d_x,d_x+d_n));
117  }
118 }

References Graph::curve(), Filter::curveData(), Filter::d_curve, Filter::d_from, Filter::d_graph, Filter::d_init_err, Filter::d_n, Filter::d_sort_data, Filter::d_to, Filter::d_x, Filter::d_y, Filter::isDataAcceptable(), and Filter::sortedCurveData().

Referenced by Fit::setDataCurve(), and Filter::setDataFromCurve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDataFromCurve() [1/2]

bool Filter::setDataFromCurve ( const QString &  curveTitle,
double  from,
double  to,
Graph g = 0 
)
inherited

Definition at line 165 of file Filter.cpp.

166 {
167  int index = curveIndex(curveTitle, g);
168  if (index < 0)
169  {
170  d_init_err = true;
171  return false;
172  }
173 
174  setDataCurve(index, from, to);
175  return true;
176 }

References Filter::curveIndex(), Filter::d_init_err, and Filter::setDataCurve().

Here is the call graph for this function:

◆ setDataFromCurve() [2/2]

bool Filter::setDataFromCurve ( const QString &  curveTitle,
Graph g = 0 
)
inherited

Definition at line 151 of file Filter.cpp.

152 {
153  int index = curveIndex(curveTitle, g);
154  if (index < 0)
155  {
156  d_init_err = true;
157  return false;
158  }
159 
160  d_graph->range(index, &d_from, &d_to);
161  setDataCurve(index, d_from, d_to);
162  return true;
163 }

References Filter::curveIndex(), Filter::d_from, Filter::d_graph, Filter::d_init_err, Filter::d_to, Graph::range(), and Filter::setDataCurve().

Referenced by FitDialog::accept(), ApplicationWindow::analyzeCurve(), Differentiation(), ExponentialFit::ExponentialFit(), FFT::FFT(), FFTFilter::FFTFilter(), MultiPeakFitTool::finalize(), ExpDecayDialog::fit(), PolynomFitDialog::fit(), GaussAmpFit::GaussAmpFit(), GaussFit::GaussFit(), Integration::Integration(), Interpolation::Interpolation(), LinearFit::LinearFit(), LorentzFit::LorentzFit(), NonLinearFit::NonLinearFit(), PluginFit::PluginFit(), PolynomialFit::PolynomialFit(), Filter::setInterval(), SigmoidalFit::SigmoidalFit(), SmoothFilter::SmoothFilter(), ThreeExpFit::ThreeExpFit(), and TwoExpFit::TwoExpFit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setInterval()

void Filter::setInterval ( double  from,
double  to 
)
inherited

Changes the data range if the source curve was already assigned. Provided for convenience.

Definition at line 79 of file Filter.cpp.

80 {
81  if (!d_curve)
82  {
83  QMessageBox::critical((ApplicationWindow *)parent(), tr("SciDAVis") + " - " + tr("Error"),
84  tr("Please assign a curve first!"));
85  return;
86  }
87  setDataFromCurve (d_curve->title().text(), from, to);
88 }

References Filter::d_curve, and Filter::setDataFromCurve().

Here is the call graph for this function:

◆ setMaximumIterations()

void Filter::setMaximumIterations ( int  iter)
inlineinherited

Sets the maximum number of iterations to be performed during an iterative session.

Definition at line 76 of file Filter.h.

76 {d_max_iterations = iter;};

References Filter::d_max_iterations.

Referenced by FitDialog::accept().

Here is the caller graph for this function:

◆ setOutputPoints()

void Filter::setOutputPoints ( int  points)
inlineinherited

Sets the number of points in the output curve.

Definition at line 70 of file Filter.h.

70 {d_points = points;};

References Filter::d_points.

Referenced by InterpolationDialog::interpolate().

Here is the caller graph for this function:

◆ setOutputPrecision()

void Filter::setOutputPrecision ( int  digits)
inlineinherited

Sets the precision used for the output.

Definition at line 73 of file Filter.h.

73 {d_prec = digits;};

References Filter::d_prec.

Referenced by ApplicationWindow::analyzeCurve(), ExpDecayDialog::fit(), and PolynomFitDialog::fit().

Here is the caller graph for this function:

◆ setTolerance()

void Filter::setTolerance ( double  eps)
inlineinherited

Sets the tolerance used by the GSL routines.

Definition at line 61 of file Filter.h.

61 {d_tolerance = eps;};

References Filter::d_tolerance.

Referenced by FitDialog::accept().

Here is the caller graph for this function:

◆ showLegend()

void Filter::showLegend ( )
virtualinherited

Adds a new legend to the plot. Calls virtual legendInfo()

Definition at line 196 of file Filter.cpp.

197 {
198  Legend* mrk = d_graph->newLegend(legendInfo());
199  if (d_graph->hasLegend())
200  {
201  Legend* legend = d_graph->legend();
202  QPoint p = legend->rect().bottomLeft();
203  mrk->setOrigin(QPoint(p.x(), p.y()+20));
204  }
205  d_graph->replot();
206 }

References Filter::d_graph, Graph::hasLegend(), Graph::legend(), Filter::legendInfo(), Graph::newLegend(), Legend::rect(), Graph::replot(), and Legend::setOrigin().

Referenced by ApplicationWindow::analyzeCurve(), ExpDecayDialog::closeEvent(), FitDialog::closeEvent(), and PolynomialFit::fit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortedCurveData()

int Filter::sortedCurveData ( QwtPlotCurve *  c,
double  start,
double  end,
double **  x,
double **  y 
)
privateinherited

Same as curveData, but sorts the points by their x value.

Definition at line 240 of file Filter.cpp.

241 {
242  if (!c || c->rtti() != QwtPlotItem::Rtti_PlotCurve)
243  return 0;
244 
245  // start/end finding only works on nondecreasing data, so sort first
246  int datasize = c->dataSize();
247  vector<double> xtemp;
248  for (int i = 0; i < datasize; i++) {
249  xtemp.push_back(c->x(i));
250  }
251  vector<size_t> p(datasize);
252  gsl_sort_index(&p[0], &xtemp[0], 1, datasize);
253 
254  // find indices that, when permuted by the sort result, give start and end
255  int i_start, i_end;
256  for (i_start = 0; i_start < datasize; i_start++)
257  if (c->x(p[i_start]) >= start)
258  break;
259  for (i_end = datasize-1; i_end >= 0; i_end--)
260  if (c->x(p[i_end]) <= end)
261  break;
262 
263  // make result arrays
264  int n = i_end - i_start + 1;
265  // TODO refactor caller code to make this mroe RAII.
266  (*x) = new double[n];
267  (*y) = new double[n];
268  for (int j = 0, i = i_start; i <= i_end; i++, j++) {
269  (*x)[j] = c->x(p[i]);
270  (*y)[j] = c->y(p[i]);
271  }
272  return n;
273 }

Referenced by Filter::setDataCurve().

Here is the caller graph for this function:

Member Data Documentation

◆ d_curve

◆ d_curveColor

QColor Filter::d_curveColor
protectedinherited

◆ d_explanation

◆ d_from

double Filter::d_from
protectedinherited

◆ d_graph

◆ d_init_err

◆ d_max_iterations

int Filter::d_max_iterations
protectedinherited

Maximum number of iterations per fit.

Definition at line 145 of file Filter.h.

Referenced by Fit::Fit(), Fit::fitGslMultifit(), Fit::fitGslMultimin(), Filter::init(), and Filter::setMaximumIterations().

◆ d_min_points

◆ d_n

unsigned Filter::d_n
protectedinherited

Size of the data arrays.

Definition at line 127 of file Filter.h.

Referenced by Convolution::addResultCurve(), Correlation::addResultCurve(), ExponentialFit::calculateFitCurveData(), TwoExpFit::calculateFitCurveData(), ThreeExpFit::calculateFitCurveData(), GaussAmpFit::calculateFitCurveData(), NonLinearFit::calculateFitCurveData(), PluginFit::calculateFitCurveData(), PolynomialFit::calculateFitCurveData(), LinearFit::calculateFitCurveData(), SigmoidalFit::calculateFitCurveData(), FFTFilter::calculateOutputData(), Interpolation::calculateOutputData(), Filter::dataSize(), Fit::errors(), Fit::evaluate_d(), Fit::evaluate_df(), Fit::evaluate_f(), FFT::FFT(), FFT::fftTable(), Fit::fit(), PolynomialFit::fit(), LinearFit::fit(), Fit::Fit(), Fit::fitGslMultifit(), Fit::fitGslMultimin(), Fit::generateFitCurve(), MultiPeakFit::generateFitCurve(), MultiPeakFit::guessInitialValues(), SigmoidalFit::guessInitialValues(), Filter::init(), FFTFilter::init(), SmoothFilter::init(), Fit::insertFitFunctionCurve(), MultiPeakFit::insertPeakFunctionCurve(), Filter::isDataAcceptable(), Integration::isDataAcceptable(), Interpolation::isDataAcceptable(), Fit::legendInfo(), Fit::logFitInfo(), Integration::logInfo(), Correlation::output(), output(), Fit::rSquare(), Filter::setDataCurve(), Fit::setDataCurve(), Correlation::setDataFromTable(), FFT::setDataFromTable(), Convolution::setDataFromTable(), Interpolation::setMethod(), Fit::setYErrorSource(), SmoothFilter::smoothAverage(), SmoothFilter::smoothFFT(), SmoothFilter::smoothModifiedSavGol(), SmoothFilter::smoothSavGol(), Integration::trapezoid(), and Filter::~Filter().

◆ d_points

◆ d_prec

int Filter::d_prec
protectedinherited

◆ d_sort_data

bool Filter::d_sort_data
protectedinherited

Specifies if the filter needs sorted data as input.

Definition at line 160 of file Filter.h.

Referenced by FFTFilter::FFTFilter(), Fit::Fit(), Filter::init(), Integration::init(), Interpolation::init(), and Filter::setDataCurve().

◆ d_table

◆ d_to

double Filter::d_to
protectedinherited

◆ d_tolerance

double Filter::d_tolerance
protectedinherited

GSL Tolerance, if ever needed...

Definition at line 136 of file Filter.h.

Referenced by Fit::Fit(), Fit::fitGslMultifit(), Fit::fitGslMultimin(), Filter::init(), Fit::logFitInfo(), and Filter::setTolerance().

◆ d_x

◆ d_y


The documentation for this class was generated from the following files:
Filter::isDataAcceptable
virtual bool isDataAcceptable()
Definition: Filter.cpp:120
ApplicationWindow::newGraph
MultiLayer * newGraph(const QString &caption=tr("Graph"))
Creates a new empty multilayer plot.
Definition: ApplicationWindow.cpp:2202
Filter::d_max_iterations
int d_max_iterations
Maximum number of iterations per fit.
Definition: Filter.h:145
Filter::d_points
int d_points
Number of result points to de calculated and displayed in the output curve.
Definition: Filter.h:139
Filter::sortedCurveData
int sortedCurveData(QwtPlotCurve *c, double start, double end, double **x, double **y)
Same as curveData, but sorts the points by their x value.
Definition: Filter.cpp:240
Differentiation::init
void init()
Definition: Differentiation.cpp:56
Graph::insertPlotItem
void insertPlotItem(QwtPlotItem *i, int type)
Definition: Graph.cpp:3281
Filter::d_x
double * d_x
x data set to be analysed
Definition: Filter.h:130
MultiLayer
An MDI window (MyWidget) managing one or more Graph objects.
Definition: MultiLayer.h:67
SciDAVis::Y
@ Y
y values
Definition: globals.h:58
Filter::d_sort_data
bool d_sort_data
Specifies if the filter needs sorted data as input.
Definition: Filter.h:160
Filter::d_to
double d_to
Definition: Filter.h:157
Filter::d_prec
int d_prec
Precision (number of significant digits) used for the results output.
Definition: Filter.h:151
Filter::d_curve
QwtPlotCurve * d_curve
The curve to be analysed.
Definition: Filter.h:148
Column
Aspect that manages a column.
Definition: Column.h:59
MultiLayer::activeGraph
Graph * activeGraph()
Definition: MultiLayer.h:124
Filter::d_tolerance
double d_tolerance
GSL Tolerance, if ever needed...
Definition: Filter.h:136
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:51
ColorButton::color
QColor color() const
Get the color of the display part.
Definition: ColorButton.cpp:140
Column::setPlotDesignation
void setPlotDesignation(SciDAVis::PlotDesignation pd)
Set the column plot designation.
Definition: Column.cpp:136
Filter::curveIndex
int curveIndex(const QString &curveTitle, Graph *g)
Performs checks and returns the index of the source data curve if OK, -1 otherwise.
Definition: Filter.cpp:129
Filter::legendInfo
virtual QString legendInfo()
Output string added to the plot as a new legend.
Definition: Filter.h:82
Filter::curveData
int curveData(QwtPlotCurve *c, double start, double end, double **x, double **y)
Sets x and y to the curve points between start and end.
Definition: Filter.cpp:275
Graph::newLegend
Legend * newLegend()
Definition: Graph.cpp:2485
Graph::insertCurve
bool insertCurve(Table *w, const QString &name, int style, int startRow=0, int endRow=-1)
Definition: Graph.cpp:3367
Graph::replot
void replot()
Definition: Graph.h:249
ApplicationWindow::newHiddenTable
Table * newHiddenTable(const QString &name, const QString &label, QList< Column * > columns)
Create a Table which is initially hidden; used to return the result of an analysis operation.
Definition: ApplicationWindow.cpp:2565
AbstractAspect::name
QString name() const
Definition: AbstractAspect.cpp:229
ApplicationWindow
SciDAVis's main window.
Definition: ApplicationWindow.h:122
Filter::d_min_points
int d_min_points
Minimum number of data points necessary to perform the operation.
Definition: Filter.h:163
Filter::output
virtual void output()
Performs the data analysis and takes care of the output.
Definition: Filter.cpp:229
Graph::Line
@ Line
Definition: Graph.h:129
Filter::d_explanation
QString d_explanation
String explaining the operation in the comment of the result table and in the project explorer.
Definition: Filter.h:166
Legend::setText
void setText(const QString &s)
Definition: Legend.cpp:85
Graph::hasLegend
bool hasLegend()
Definition: Graph.h:364
Legend::rect
QRect rect() const
Bounding rectangle in paint coordinates.
Definition: Legend.cpp:106
Filter::d_graph
Graph * d_graph
The graph where the result curve should be displayed.
Definition: Filter.h:118
Graph::legend
Legend * legend()
Definition: Graph.cpp:1796
Filter::d_curveColor
QColor d_curveColor
Color index of the result curve.
Definition: Filter.h:142
Legend::setOrigin
void setOrigin(const QPoint &p)
Definition: Legend.cpp:142
Filter::setDataCurve
virtual void setDataCurve(int curve, double start, double end)
Definition: Filter.cpp:90
Filter::d_from
double d_from
Data interval.
Definition: Filter.h:157
COLORVALUE
static QString COLORVALUE(QString s)
Definition: ColorButton.h:43
DataCurve
Definition: PlotCurve.h:52
ColorButton::isValidColor
static bool isValidColor(const QColor &color)
Returns TRUE if the color is included in the color box, otherwise returns FALSE.
Definition: ColorButton.cpp:168
Filter::logInfo
virtual QString logInfo()
Output string added to the log pannel of the application.
Definition: Filter.h:112
Filter::d_n
unsigned d_n
Size of the data arrays.
Definition: Filter.h:127
SciDAVis::X
@ X
x values
Definition: globals.h:57
SciDAVis::Numeric
@ Numeric
column contains doubles
Definition: globals.h:67
Filter::setDataFromCurve
bool setDataFromCurve(const QString &curveTitle, Graph *g=0)
Definition: Filter.cpp:151
Filter::Filter
Filter(ApplicationWindow *parent, Table *t=0, QString name=QString())
Definition: Filter.cpp:54
Filter::d_init_err
bool d_init_err
Error flag telling if something went wrong during the initialization phase.
Definition: Filter.h:154
Graph::updatePlot
void updatePlot()
Definition: Graph.cpp:3474
Filter::d_y
double * d_y
y data set to be analysed
Definition: Filter.h:133
Graph::curve
QwtPlotCurve * curve(int index) const
get curve by index
Definition: Graph.cpp:2821
ApplicationWindow::generateUniqueName
QString generateUniqueName(const QString &name, bool increment=true)
Definition: ApplicationWindow.cpp:13503
Graph::curveIndex
int curveIndex(long key) const
Definition: Graph.h:199
Legend
A piece of text to be drawn on a Plot.
Definition: Legend.h:56
Column::setValueAt
void setValueAt(int row, double new_value)
Set the content of row 'row'.
Definition: Column.cpp:229
Graph::range
int range(int index, double *start, double *end)
Definition: Graph.cpp:2834