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.cpp
Go to the documentation of this file.
1 
11 
29 #include "Differentiation.h"
30 #include "MultiLayer.h"
31 #include "Legend.h"
32 #include "core/column/Column.h"
33 
34 #include <QLocale>
35 
37 : Filter(parent, g)
38 {
39  init();
40 }
41 
42 Differentiation::Differentiation(ApplicationWindow *parent, Graph *g, const QString& curveTitle)
43 : Filter(parent, g)
44 {
45  init();
46  setDataFromCurve(curveTitle);
47 }
48 
49 Differentiation::Differentiation(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end)
50 : Filter(parent, g)
51 {
52  init();
53  setDataFromCurve(curveTitle, start, end);
54 }
55 
57 {
58  setObjectName(tr("Derivative"));
59  d_min_points = 4;
60 }
61 
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 }
82 
ApplicationWindow::newGraph
MultiLayer * newGraph(const QString &caption=tr("Graph"))
Creates a new empty multilayer plot.
Definition: ApplicationWindow.cpp:2202
Differentiation::Differentiation
Differentiation(ApplicationWindow *parent, Graph *g)
Definition: Differentiation.cpp:36
Differentiation::init
void init()
Definition: Differentiation.cpp:56
Column.h
Filter::d_x
double * d_x
x data set to be analysed
Definition: Filter.h:130
Differentiation.h
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_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
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:51
Column::setPlotDesignation
void setPlotDesignation(SciDAVis::PlotDesignation pd)
Set the column plot designation.
Definition: Column.cpp:136
Filter
Abstract base class for data analysis operations.
Definition: Filter.h:42
MultiLayer.h
Graph::insertCurve
bool insertCurve(Table *w, const QString &name, int style, int startRow=0, int endRow=-1)
Definition: Graph.cpp:3367
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
Legend.h
Legend::setText
void setText(const QString &s)
Definition: Legend.cpp:85
Graph::legend
Legend * legend()
Definition: Graph.cpp:1796
Filter::d_n
unsigned d_n
Size of the data arrays.
Definition: Filter.h:127
Graph
A 2D-plotting widget.
Definition: Graph.h:119
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::d_y
double * d_y
y data set to be analysed
Definition: Filter.h:133
ApplicationWindow::generateUniqueName
QString generateUniqueName(const QString &name, bool increment=true)
Definition: ApplicationWindow.cpp:13503
Differentiation::output
void output()
Performs the data analysis and takes care of the output.
Definition: Differentiation.cpp:62
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