本文整理汇总了C++中DataCurve类的典型用法代码示例。如果您正苦于以下问题:C++ DataCurve类的具体用法?C++ DataCurve怎么用?C++ DataCurve使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataCurve类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
void Fit::setDataCurve(int curve, double start, double end) {
if (!d_graph)
return;
if (d_n > 0)
delete[] d_w;
Filter::setDataCurve(curve, start, end);
d_w = new double[d_n];
PlotCurve *plotCurve = dynamic_cast<PlotCurve *>(d_curve);
DataCurve *dataCurve = dynamic_cast<DataCurve *>(d_curve);
// if it is a DataCurve (coming from a Table)
if (plotCurve && dataCurve && plotCurve->type() != GraphOptions::Function) {
QList<DataCurve *> lst = dataCurve->errorBarsList();
foreach (DataCurve *c, lst) {
QwtErrorPlotCurve *er = dynamic_cast<QwtErrorPlotCurve *>(c);
if (er && !er->xErrors()) {
d_weighting = Instrumental;
for (int i = 0; i < d_n; i++)
d_w[i] = er->errorValue(i); // d_w are equal to the error bar values
weighting_dataset = er->title().text();
return;
}
}
示例2: tr
QwtPlotCurve* Filter::addResultCurve(double *x, double *y)
{
ApplicationWindow *app = (ApplicationWindow *)parent();
QLocale locale = app->locale();
const QString tableName = app->generateUniqueName(QString(objectName()));
QString dataSet;
if (d_curve)
dataSet = d_curve->title().text();
else
dataSet = d_y_col_name;
d_result_table = app->newHiddenTable(tableName, d_explanation + " " + tr("of") + " " + dataSet, d_points, 2);
for (int i=0; i<d_points; i++){
d_result_table->setText(i, 0, locale.toString(x[i], 'e', app->d_decimal_digits));
d_result_table->setText(i, 1, locale.toString(y[i], 'e', app->d_decimal_digits));
}
DataCurve *c = 0;
if (d_graphics_display){
c = new DataCurve(d_result_table, tableName + "_1", tableName + "_2");
c->setData(x, y, d_points);
c->setPen(QPen(ColorBox::color(d_curveColorIndex), 1));
if (!d_output_graph)
d_output_graph = createOutputGraph()->activeGraph();
d_output_graph->insertPlotItem(c, Graph::Line);
d_output_graph->updatePlot();
}
return (QwtPlotCurve*)c;
}
示例3: initializeFromCurve
/**
* Called from constructor.
* Sets up tool based on the given curve.
* @param curve :: [input] Curve to use for initialization
* @returns :: success or failure
*/
bool PeakPickerTool::initializeFromCurve(PlotCurve *curve) {
if (!curve) {
return false;
}
DataCurve *dcurve = dynamic_cast<DataCurve *>(curve);
if (dcurve) {
m_wsName = dcurve->table()->name().section('-', 0, 0);
m_spec = dcurve->table()->colName(0).section('_', 1, 1).mid(2).toInt();
} else {
MantidMatrixCurve *mcurve = dynamic_cast<MantidMatrixCurve *>(curve);
if (mcurve) {
const QString title = mcurve->title().text();
if (title.contains("Workspace-Calc")) {
// Don't set up from a fit curve
return false;
} else {
// Set up the tool from this curve
m_wsName = mcurve->workspaceName();
m_spec = mcurve->workspaceIndex();
m_shouldBeNormalised =
mcurve->isDistribution() && mcurve->isNormalizable();
}
} else {
return false;
}
}
return true;
}
示例4: QPen
void BaselineDialog::createBaseline()
{
ApplicationWindow *app = (ApplicationWindow *)parent();
QPen pen = QPen(Qt::red);
if (d_baseline){
pen = d_baseline->pen();
graph->removeCurve(d_baseline->title().text());
delete d_baseline;
d_baseline = NULL;
if (d_table){
d_table->askOnCloseEvent(false);
app->closeWindow(d_table);
d_table = NULL;
}
}
disableBaselineTool();
if (btnAutomatic->isChecked()){
Interpolation *i = new Interpolation(app, graph, boxInputName->currentText(), boxInterpolationMethod->currentIndex());
i->setOutputPoints(boxPoints->value());
i->run();
delete i;
d_baseline = graph->dataCurve(graph->curveCount() - 1);
d_table = ((DataCurve *)d_baseline)->table();
} else if (btnEquation->isChecked()){
double start = graph->axisScaleDiv(QwtPlot::xBottom)->lowerBound();
double end = graph->axisScaleDiv(QwtPlot::xBottom)->upperBound();
DataCurve *c = graph->dataCurve(graph->curveIndex(boxInputName->currentText()));
if (c){
start = c->minXValue();
end = c->maxXValue();
}
d_baseline = graph->addFunction(QStringList() << boxEquation->text(), start, end, boxPoints->value(), "x", FunctionCurve::Normal, tr("Baseline"));
} else if (btnDataset->isChecked()){
Table *t = app->table(boxTableName->currentText());
if (t){
int rows = t->numRows();
d_table = app->newTable(rows, 2);
app->setWindowName(d_table, tr("Baseline"));
app->hideWindow(d_table);
int ycol = t->colIndex(boxColumnName->currentText());
int xcol = t->colX(ycol);
for (int i = 0; i < rows; i++){
d_table->setText(i, 0, t->text(i, xcol));
d_table->setText(i, 1, t->text(i, ycol));
}
d_baseline = graph->insertCurve(d_table, d_table->objectName() + "_2", Graph::Line, 0, -1);
graph->setAutoScale();
}
}
if (d_baseline){
d_baseline->setPen(pen);
graph->replot();
}
}
示例5: curvesList
void Plot::updateCurveLabels()
{
QList<QwtPlotItem *> curves = curvesList();
foreach(QwtPlotItem *i, curves){
DataCurve * dc = dynamic_cast<DataCurve *>(i);
if(dc && i->rtti() != QwtPlotItem::Rtti_PlotSpectrogram &&
dc->type() != Graph::Function &&
dc->hasLabels())
dc->updateLabelsPosition();
}
示例6: x_temp
void Correlation::addResultCurve()
{
ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(parent());
if (!app)
return;
QLocale locale = app->locale();
if (d_n > d_table->numRows())
d_table->setNumRows(d_n);
int cols = d_table->numCols();
int cols2 = cols+1;
d_table->addCol();
d_table->addCol();
int n = d_n/2;
QVarLengthArray<double> x_temp(d_n), y_temp(d_n);//double x_temp[d_n], y_temp[d_n];
for (int i = 0; i<d_n; i++){
double x = i - n;
x_temp[i] = x;
double y;
if(i < n)
y = d_x[n + i];
else
y = d_x[i - n];
y_temp[i] = y;
d_table->setText(i, cols, QString::number(x));
d_table->setText(i, cols2, locale.toString(y, 'g', app->d_decimal_digits));
}
QStringList l = d_table->colNames().grep(tr("Lag"));
QString id = QString::number((int)l.size()+1);
QString label = objectName() + id;
d_table->setColName(cols, tr("Lag") + id);
d_table->setColName(cols2, label);
d_table->setColPlotDesignation(cols, Table::X);
d_table->setHeaderColType();
if (d_graphics_display){
if (!d_output_graph)
d_output_graph = createOutputGraph()->activeGraph();
DataCurve *c = new DataCurve(d_table, d_table->colName(cols), d_table->colName(cols2));
c->setData(x_temp.data(), y_temp.data(), d_n);//c->setData(x_temp, y_temp, d_n);
c->setPen(QPen(ColorBox::color(d_curveColorIndex), 1));
d_output_graph->insertPlotItem(c, Graph::Line);
d_output_graph->updatePlot();
}
}
示例7: if
void AssociationsDialog::changePlotAssociation(int curve, const QStringList& ass)
{
DataCurve *c = (DataCurve *)graph->dataCurve(curvesIndicesList[curve]);
if (!c)
return;
if (c->plotAssociation() == ass)
return;
QStringList lst = ass;
if (lst.count() == 1){
c->setTitle(lst[0]);
if (c->type() == Graph::Box)
((BoxCurve*)c)->loadData();
else if (c->type() == Graph::Pie)
((PieCurve*)c)->loadData();
else if (c->type() == Graph::Histogram)
((QwtHistogram*)c)->loadData();
} else if (lst.count() == 2){
c->setXColumnName(lst[0].remove("(X)"));
c->setTitle(lst[1].remove("(Y)"));
c->loadData();
} else if (lst.count() == 3){//curve with error bars
ErrorBarsCurve *er = (ErrorBarsCurve *)c;
QString xColName = lst[0].remove("(X)");
QString yColName = lst[1].remove("(Y)");
QString erColName = lst[2].remove("(xErr)").remove("(yErr)");
DataCurve *master_curve = graph->masterCurve(xColName, yColName);
if (!master_curve)
return;
int type = ErrorBarsCurve::Vertical;
if (ass.join(",").contains("(xErr)"))
type = ErrorBarsCurve::Horizontal;
er->setDirection(type);
er->setTitle(erColName);
if (master_curve != er->masterCurve())
er->setMasterCurve(master_curve);
else
er->loadData();
} else if (lst.count() == 4){
VectorCurve *v = (VectorCurve *)c;
v->setXColumnName(lst[0].remove("(X)"));
v->setTitle(lst[1].remove("(Y)"));
QString xEndCol = lst[2].remove("(X)").remove("(A)");
QString yEndCol = lst[3].remove("(Y)").remove("(M)");
if (v->vectorEndXAColName() != xEndCol || v->vectorEndYMColName() != yEndCol)
v->setVectorEnd(xEndCol, yEndCol);
else
v->loadData();
}
graph->notifyChanges();
}
示例8: x_temp
void Convolution::addResultCurve()
{
ApplicationWindow *app = (ApplicationWindow *)parent();
if (!app)
return;
int cols = d_table->numCols();
int cols2 = cols+1;
d_table->addCol();
d_table->addCol();
#ifdef Q_CC_MSVC
QVarLengthArray<double> x_temp(d_n);
#else
double x_temp[d_n];
#endif
QLocale locale = app->locale();
for (int i = 0; i<d_n; i++){
double x = i+1;
x_temp[i] = x;
d_table->setText(i, cols, QString::number(x));
d_table->setText(i, cols2, locale.toString(d_x[i], 'g', app->d_decimal_digits));
}
QStringList l = d_table->colNames().grep(tr("Index"));
QString id = QString::number((int)l.size()+1);
QString label = objectName() + id;
d_table->setColName(cols, tr("Index") + id);
d_table->setColName(cols2, label);
d_table->setColPlotDesignation(cols, Table::X);
d_table->setHeaderColType();
if (d_graphics_display){
if (!d_output_graph)
createOutputGraph();
DataCurve *c = new DataCurve(d_table, d_table->colName(cols), d_table->colName(cols2));
#ifdef Q_CC_MSVC
c->setData(x_temp.data(), d_x, d_n);
#else
c->setData(x_temp, d_x, d_n);
#endif
c->setPen(QPen(ColorBox::color(d_curveColorIndex), 1));
d_output_graph->insertPlotItem(c, Graph::Line);
d_output_graph->updatePlot();
}
}
示例9: 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()));
}
示例10: canvasMap
/**
* Returns the index of the closest curve to a point on the canvas.
* Also returns index of the nearest data point on that curve.
* @param xpos :: x coordinate of a point on the canvas in pixels.
* @param ypos :: y coordinate of a point on the canvas in pixels.
* @param dist :: ?
* @param point :: Output index of the nearest data point to the point with coordinates (xpos,ypos)
*/
int Plot::closestCurve(int xpos, int ypos, int &dist, int &point)
{
QwtScaleMap map[QwtPlot::axisCnt];
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
map[axis] = canvasMap(axis);
double dmin = std::numeric_limits<double>::max();
int key = -1;
for (QMap<int, QwtPlotItem *>::iterator iter = d_curves.begin(); iter != d_curves.end(); ++iter )
{
QwtPlotItem *item = (QwtPlotItem *)iter.data();
if (!item)
continue;
if(item->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
{
PlotCurve *c = (PlotCurve *)item;
DataCurve *dc = dynamic_cast<DataCurve *>(item);
if (dc)
{
if (c->type() != Graph::Function && dc->hasLabels() &&
dc->selectedLabels(QPoint(xpos, ypos))){
dist = 0;
return iter.key();
} else
dc->setLabelsSelected(false);
}
for (int i=0; i<c->dataSize(); i++)
{
double cx = map[c->xAxis()].xTransform(c->x(i)) - double(xpos);
double cy = map[c->yAxis()].xTransform(c->y(i)) - double(ypos);
double f = qwtSqr(cx) + qwtSqr(cy);
if (f < dmin && c->type() != Graph::ErrorBars)
{
dmin = f;
key = iter.key();
point = i;
}
}
}
}
dist = static_cast<int>(sqrt(dmin));
return key;
}
示例11: name
void Correlation::addResultCurve()
{
ApplicationWindow *app = (ApplicationWindow *)parent();
if (!app)
return;
int rows = d_table->numRows();
int cols = d_table->numCols();
int cols2 = cols+1;
d_table->addCol();
d_table->addCol();
int n = rows/2;
double x_temp[rows], y_temp[rows];
for (int i = 0; i<rows; i++)
{
x_temp[i] = i - n;
if(i < n)
y_temp[i] = d_x[d_n - n + i];
else
y_temp[i] = d_x[i-n];
d_table->column(cols)->setValueAt(i, x_temp[i]);
d_table->column(cols2)->setValueAt(i, y_temp[i]);
}
QStringList l = d_table->colNames().grep(tr("Lag"));
QString id = QString::number((int)l.size()+1);
QString label = name() + id;
d_table->setColName(cols, tr("Lag") + id);
d_table->setColName(cols2, label);
d_table->setColPlotDesignation(cols, SciDAVis::X);
MultiLayer *ml = app->newGraph(name() + tr("Plot"));
if (!ml)
return;
DataCurve *c = new DataCurve(d_table, d_table->colName(cols), d_table->colName(cols2));
c->setData(x_temp, y_temp, rows);
c->setPen(QPen(ColorBox::color(d_curveColorIndex), 1));
ml->activeGraph()->insertPlotItem(c, Graph::Line);
ml->activeGraph()->updatePlot();
}
示例12: PlotCurve
DataCurve::DataCurve(const DataCurve &c)
: PlotCurve(c.title().text()), d_table(c.d_table), d_x_column(c.d_x_column),
d_start_row(c.d_start_row), d_end_row(c.d_end_row),
d_labels_column(c.d_labels_column), d_click_pos_x(c.d_click_pos_x),
d_click_pos_y(c.d_click_pos_y), d_labels_color(c.d_labels_color),
d_labels_font(c.d_labels_font), d_labels_angle(c.d_labels_angle),
d_white_out_labels(c.d_white_out_labels),
d_labels_align(c.d_labels_align), d_labels_x_offset(c.d_labels_x_offset),
d_labels_y_offset(c.d_labels_y_offset),
d_selected_label(c.d_selected_label) {}
示例13: 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()));
}
示例14: if
void AssociationsDialog::changePlotAssociation(int curve, const QString &text) {
DataCurve *c = (DataCurve *)graph->curve(curve); // c_keys[curve]);
if (!c) return;
if (c->plotAssociation() == text) return;
QStringList lst = text.split(",", QString::SkipEmptyParts);
if (lst.count() == 2) {
c->setXColumnName(lst[0].remove("(X)"));
c->setTitle(lst[1].remove("(Y)"));
c->loadData();
} else if (lst.count() == 3) { // curve with error bars
QwtErrorPlotCurve *er = (QwtErrorPlotCurve *)c;
QString xColName = lst[0].remove("(X)");
QString yColName = lst[1].remove("(Y)");
QString erColName = lst[2].remove("(xErr)").remove("(yErr)");
DataCurve *master_curve = graph->masterCurve(xColName, yColName);
if (!master_curve) return;
int type = QwtErrorPlotCurve::Vertical;
if (text.contains("(xErr)")) type = QwtErrorPlotCurve::Horizontal;
er->setDirection(type);
er->setTitle(erColName);
if (master_curve != er->masterCurve())
er->setMasterCurve(master_curve);
else
er->loadData();
} else if (lst.count() == 4) {
VectorCurve *v = (VectorCurve *)c;
v->setXColumnName(lst[0].remove("(X)"));
v->setTitle(lst[1].remove("(Y)"));
QString xEndCol = lst[2].remove("(X)").remove("(A)");
QString yEndCol = lst[3].remove("(Y)").remove("(M)");
if (v->vectorEndXAColName() != xEndCol ||
v->vectorEndYMColName() != yEndCol)
v->setVectorEnd(xEndCol, yEndCol);
else
v->loadData();
}
graph->notifyChanges();
}
示例15: QMAX
void CurveRangeDialog::accept()
{
if (!d_graph)
return;
int start = boxStart->value() - 1;
int end = boxEnd->value() - 1;
if (boxApplyToAll->isChecked()){
for (int i = 0; i < d_graph->curveCount(); i++){
DataCurve *c = d_graph->dataCurve(i);
if (c)
c->setRowRange(QMIN(start, end), QMAX(start, end));
}
} else if (!d_curves.isEmpty()){
foreach(DataCurve *c, d_curves)
c->setRowRange(QMIN(start, end), QMAX(start, end));
}
d_graph->updatePlot();
d_graph->notifyChanges();
close();
}