void PlotCurve::computeWaterfallOffsets() { Plot *plot = static_cast<Plot *>(this->plot()); Graph *g = static_cast<Graph *>(plot->parent()); // reset the offsets d_x_offset = 0.0; d_y_offset = 0.0; if (g->isWaterfallPlot()){ int index = g->curveIndex(this); int curves = g->curves();//Count(); PlotCurve *c = dynamic_cast<PlotCurve*>(g->curve(0)); // Get the minimum value of the first curve in this plot double ymin = c->minYValue(); if (index > 0 && c){ d_x_offset = index*g->waterfallXOffset()*0.01*plot->canvas()->width()/(double)(curves - 1); d_y_offset = index*g->waterfallYOffset()*0.01*plot->canvas()->height()/(double)(curves - 1); setZ(-index); setBaseline(ymin-d_y_offset); // Fill down to minimum value of first curve } else { setZ(0); setBaseline(ymin); // This is for when 'fill under curve' is turn on } if (g->grid()) g->grid()->setZ(-g->curves()/*Count()*/ - 1); } }
void BitmapFont::setBaseline(int baseline, const std::string& glyphs) { for (auto& glyph : glyphs) setBaseline(baseline, glyph); }
void BitmapFont::setBaselines(const std::vector<int>& baselines, unsigned int initialGlyphIndex) { for (unsigned int i{ 0 }; i < baselines.size(); ++i) setBaseline(baselines[i], initialGlyphIndex + i); }
void BitmapFont::setBaselines(int baseline, unsigned int numberOfGlyphs, unsigned int initialGlyphIndex) { for (unsigned int i{ 0 }; i < numberOfGlyphs; ++i) setBaseline(baseline, initialGlyphIndex + i); }
void DataCurve::loadData() { Graph *g = (Graph *)plot(); if (!g) return; int xcol = d_x_table->colIndex(d_x_column); int ycol = d_table->colIndex(title().text()); if (xcol < 0 || ycol < 0) { remove(); return; } int rows = d_table->numRows(); if (d_end_row < 0 || d_end_row >= rows) d_end_row = rows - 1; int xColType = d_x_table->columnType(xcol); int yColType = d_table->columnType(ycol); int r = abs(d_end_row - d_start_row) + 1; QPolygonF data; data.reserve(r); QStringList xLabels, yLabels;// store text labels int xAxis = QwtPlot::xBottom; if (d_type == Graph::HorizontalBars) xAxis = QwtPlot::yLeft; QString date_time_fmt = d_table->columnFormat(xcol); int size = 0, from = 0; d_data_ranges.clear(); for (int i = d_start_row; i <= d_end_row; i++ ) { QString xval = d_x_table->text(i, xcol); QString yval = d_table->text(i, ycol); if (!xval.isEmpty() && !yval.isEmpty()) { bool valid_data = true; QPointF p; if (xColType == Table::Text) { xLabels << xval; p.setX((double)(size + 1)); } else if (xColType == Table::Time) p.setX(Table::fromTime(QTime::fromString(xval.trimmed(), date_time_fmt))); else if (xColType == Table::Date) p.setX(Table::fromDateTime(QDateTime::fromString(xval.trimmed(), date_time_fmt))); else p.setX(g->locale().toDouble(xval, &valid_data)); if (yColType == Table::Text) { yLabels << yval; p.setY((double)(size + 1)); } else p.setY(g->locale().toDouble(yval, &valid_data)); if (valid_data) { data << p; size++; } } else if (from < size) { DataRange range; range.from = from; range.to = size - 1; d_data_ranges.push_back(range); from = size; } } if (d_data_ranges.size() && from < size) { DataRange range; range.from = from; range.to = size - 1; d_data_ranges.push_back(range); } if (!size) { remove(); return; } data.resize(size); if (g->isWaterfallPlot()) { int index = g->curveIndex(this); int curves = g->curveCount(); DataCurve *c = g->dataCurve(0); if (index > 0 && c) { double xmin = c->minXValue(); double dx = index*g->waterfallXOffset()*0.01*g->canvas()->width()/(double)(curves - 1); d_x_offset = g->invTransform(xAxis, g->transform(xAxis, xmin) + dx) - xmin; double ymin = c->minYValue(); double dy = index*g->waterfallYOffset()*0.01*g->canvas()->height()/(double)(curves - 1); d_y_offset = ymin - g->invTransform(yAxis(), g->transform(yAxis(), ymin) + dy); setZ(-index); setBaseline(d_y_offset); data.translate(d_x_offset, d_y_offset); } else { setZ(0); setBaseline(0.0); } if (g->grid()) g->grid()->setZ(-g->curveCount() - 1); } double speedTol = g->getDouglasPeukerTolerance(); if (speedTol != 0.0 && size >= g->speedModeMaxPoints()) { QwtWeedingCurveFitter *fitter = new QwtWeedingCurveFitter(speedTol); data = fitter->fitCurve(data); delete fitter; } if (d_type == Graph::HorizontalBars) { size = data.size(); for (int i = 0; i < size; i++) { QPointF p = data.at(i); data[i] = QPointF(p.y(), p.x()); } } setData(data); foreach(ErrorBarsCurve *c, d_error_bars) c->setData(data); if (xColType == Table::Text) g->setLabelsTextFormat(xAxis, ScaleDraw::Text, d_x_column, xLabels); if (yColType == Table::Text) g->setLabelsTextFormat(QwtPlot::yLeft, ScaleDraw::Text, title().text(), yLabels); setRenderHint(QwtPlotItem::RenderAntialiased, g->isCurveAntialiasingEnabled(this)); if (!d_labels_list.isEmpty()) { ((Graph*)plot())->updatePlot(); loadLabels(); } }
int QDeclarativeAnchorSet::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QDeclarativeScriptString*>(_v) = left(); break; case 1: *reinterpret_cast< QDeclarativeScriptString*>(_v) = right(); break; case 2: *reinterpret_cast< QDeclarativeScriptString*>(_v) = horizontalCenter(); break; case 3: *reinterpret_cast< QDeclarativeScriptString*>(_v) = top(); break; case 4: *reinterpret_cast< QDeclarativeScriptString*>(_v) = bottom(); break; case 5: *reinterpret_cast< QDeclarativeScriptString*>(_v) = verticalCenter(); break; case 6: *reinterpret_cast< QDeclarativeScriptString*>(_v) = baseline(); break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setLeft(*reinterpret_cast< QDeclarativeScriptString*>(_v)); break; case 1: setRight(*reinterpret_cast< QDeclarativeScriptString*>(_v)); break; case 2: setHorizontalCenter(*reinterpret_cast< QDeclarativeScriptString*>(_v)); break; case 3: setTop(*reinterpret_cast< QDeclarativeScriptString*>(_v)); break; case 4: setBottom(*reinterpret_cast< QDeclarativeScriptString*>(_v)); break; case 5: setVerticalCenter(*reinterpret_cast< QDeclarativeScriptString*>(_v)); break; case 6: setBaseline(*reinterpret_cast< QDeclarativeScriptString*>(_v)); break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { switch (_id) { case 0: resetLeft(); break; case 1: resetRight(); break; case 2: resetHorizontalCenter(); break; case 3: resetTop(); break; case 4: resetBottom(); break; case 5: resetVerticalCenter(); break; case 6: resetBaseline(); break; } _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }