本文整理汇总了C++中DataCurve::dataSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DataCurve::dataSize方法的具体用法?C++ DataCurve::dataSize怎么用?C++ DataCurve::dataSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataCurve
的用法示例。
在下文中一共展示了DataCurve::dataSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setGraph
void BaselineDialog::setGraph(Graph *g)
{
if (!g)
return;
graph = g;
DataCurve *c = g->dataCurve(0);
if (c)
boxPoints->setValue(c->dataSize());
boxInputName->addItems(g->analysableCurvesList());
if (g->rangeSelectorsEnabled())
boxInputName->setCurrentIndex(boxInputName->findText(g->curveRange(g->rangeSelectorTool()->selectedCurve())));
connect (graph, SIGNAL(destroyed()), this, SLOT(close()));
connect (graph, SIGNAL(modifiedGraph()), this, SLOT(updateGraphCurves()));
}
示例2: setGraph
void BaselineDialog::setGraph(Graph *g)
{
if (!g)
return;
graph = g;
DataCurve *c = g->dataCurve(0);
if (c)
boxPoints->setValue(c->dataSize());
boxInputName->addItems(g->analysableCurvesList());
QString selectedCurve = g->selectedCurveTitle();
if (!selectedCurve.isEmpty())
boxInputName->setCurrentIndex(boxInputName->findText(selectedCurve));
connect (graph, SIGNAL(destroyed()), this, SLOT(close()));
connect (graph, SIGNAL(modifiedGraph()), this, SLOT(updateGraphCurves()));
}
示例3: add
void ErrDialog::add()
{
ApplicationWindow *app = qobject_cast<ApplicationWindow *>(parent());
if (!app)
return;
MultiLayer *plot = (MultiLayer *)app->activeWindow(ApplicationWindow::MultiLayerWindow);
if (!plot)
return;
Graph* g = plot->activeLayer();
if (!g)
return;
QString name = nameLabel->currentText();
DataCurve *curve = g->dataCurve(name);
if (!curve){
QMessageBox::critical(app, tr("QtiPlot - Error"),
tr("This feature is not available for user defined function curves!"));
return;
}
int direction = xErrBox->isChecked() ? 0 : 1;
ErrorBarsCurve *er = NULL;
if (columnBox->isChecked()){
QString errColumnName = tableNamesBox->currentText() + "_" + colNamesBox->currentText();
Table *errTable = app->table(errColumnName);
if (!errTable)
return;
/*if (w->numRows() != errTable->numRows()){
QMessageBox::critical(app, tr("QtiPlot - Error"), tr("The selected columns have different numbers of rows!"));
return;
}*/
if (errTable->isEmptyColumn(errTable->colIndex(errColumnName))){
QMessageBox::critical(app, tr("QtiPlot - Error"), tr("The selected error column is empty!"));
return;
}
er = g->addErrorBars(curve, errTable, errColumnName, direction);
} else {
Table *t = curve->table();
if (!t)
return;
if (direction == ErrorBarsCurve::Horizontal)
t->addCol(Table::xErr);
else
t->addCol(Table::yErr);
int r = curve->dataSize();
int rows = t->numRows();
int col = t->numCols() - 1;
int ycol = t->colIndex(curve->title().text());
if (!direction)
ycol = t->colIndex(curve->xColumnName());
QVarLengthArray<double> Y(r);
if (direction == ErrorBarsCurve::Horizontal){
for (int i = 0; i < r; i++)
Y[i] = curve->x(i);
} else {
for (int i = 0; i < r; i++)
Y[i] = curve->y(i);
}
if (percentBox->isChecked()){
double prc = 0.01*valueBox->value();
int aux = 0;
for (int i = curve->startRow(); i <= curve->endRow(); i++){
if (!t->text(i, ycol).isEmpty() && aux < r){
t->setCell(i, col, Y[aux]*prc);
aux++;
}
}
} else if (standardBox->isChecked() || standardErrorBox->isChecked()){
double sd = gsl_stats_sd(Y.data(), 1, r);
if (standardErrorBox->isChecked())
sd /= sqrt(r);
for (int i = 0; i < rows; i++){
if (!t->text(i, ycol).isEmpty())
t->setCell(i, col, sd);
}
}
er = g->addErrorBars(curve, t, t->colName(col), direction);
}
if (er){
er->setColor(curve->pen().color());
g->replot();
plot->notifyChanges();
}
}
示例4: subtractBaseline
void BaselineDialog::subtractBaseline(bool add)
{
if (!d_baseline)
return;
disableBaselineTool();
if (!graph)
return;
QString name = boxInputName->currentText();
DataCurve *c = graph->dataCurve(graph->curveIndex(name.left(name.indexOf(" ["))));
if (!c)
return;
ApplicationWindow *app = (ApplicationWindow *)parent();
if (!app)
return;
Table *inputTable = c->table();
if (!inputTable)
return;
int startRow = c->startRow(), endRow = c->endRow();
if (startRow < 0)
startRow = 0;
if (endRow < 0)
endRow = c->dataSize() - 1;
int xCol = inputTable->colIndex(c->xColumnName());
int yCol = inputTable->colIndex(c->title().text());
int refPoints = d_baseline->dataSize();
double *x = (double *)malloc(refPoints*sizeof(double));
if (!x)
return;
double *y = (double *)malloc(refPoints*sizeof(double));
if (!y){
free (x);
return;
}
for (int i = 0; i < refPoints; i++){
x[i] = d_baseline->x(i);
y[i] = d_baseline->y(i);
}
//sort data with respect to x value
size_t *p = (size_t *)malloc(refPoints*sizeof(size_t));
if (!p){
free(x); free(y);
return;
}
gsl_sort_index(p, x, 1, refPoints);
double *xtemp = (double *)malloc(refPoints*sizeof(double));
if (!xtemp){
free(x); free(y); free(p);
return;
}
double *ytemp = (double *)malloc(refPoints*sizeof(double));
if (!ytemp){
free(x); free(y); free(p); free(xtemp);
return;
}
for (int i = 0; i < refPoints; i++){
xtemp[i] = x[p[i]];
ytemp[i] = y[p[i]];
}
free(x);
free(y);
free(p);
//make linear interpolation on sorted data
gsl_interp_accel *acc = gsl_interp_accel_alloc();
gsl_spline *interp = gsl_spline_alloc(gsl_interp_linear, refPoints);
gsl_spline_init (interp, xtemp, ytemp, refPoints);
for (int i = startRow; i <= endRow; i++){
if (!inputTable->text(i, yCol).isEmpty() && !inputTable->text(i, xCol).isEmpty())
inputTable->setCell(i, yCol, combineValues(inputTable->cell(i, yCol), gsl_spline_eval(interp, inputTable->cell(i, xCol), acc), add));
}
inputTable->notifyChanges(c->title().text());
gsl_spline_free (interp);
gsl_interp_accel_free (acc);
free(xtemp);
free(ytemp);
}