本文整理汇总了C++中QCPGraph::name方法的典型用法代码示例。如果您正苦于以下问题:C++ QCPGraph::name方法的具体用法?C++ QCPGraph::name怎么用?C++ QCPGraph::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCPGraph
的用法示例。
在下文中一共展示了QCPGraph::name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pointInfo
void DataExplorer::pointInfo(QMouseEvent *event)
{
QCPAbstractPlottable *plottable = ui->runPlot->plottableAt(event->localPos());
if (!plottable) return;
double x = ui->runPlot->xAxis->pixelToCoord(event->localPos().x());
QToolTip::hideText();
QCPGraph *graph = qobject_cast<QCPGraph*>(plottable);
if (graph) {
double key = 0;
double value = 0;
bool ok = false;
double m = std::numeric_limits<double>::max();
for (QCPData data : graph->data()->values()) {
double d = qAbs(x - data.key);
if(d < m) {
key = data.key;
value = data.value;
ok = true;
m = d;
}
}
if (!ok) return;
QToolTip::showText(event->globalPos(),
tr("<center><b>%L1</b><br/>%L2 %[email protected] %L4s</center>").
arg(graph->name().isEmpty() ? "..." : graph->name()).
arg(value).arg(graph->property("unit").toString()).
arg(key),
ui->runPlot, ui->runPlot->rect());
return;
}
QCPStatisticalBox *graphBox = qobject_cast<QCPStatisticalBox*>(plottable);
if (graphBox) {
QToolTip::showText(event->globalPos(),
tr("<center><b>%L1</b><br/></center>Max: %2<br/>Upper: %3<br/>Median: %4<br/>Lower: %5<br/>Min: %6<br/>StdDev: %7<br/>Avg: %8<br/>Avg Time: %9").
arg(graphBox->name().isEmpty() ? "..." : graphBox->name()).
arg(graphBox->maximum()).arg(graphBox->upperQuartile()).arg(graphBox->median()).
arg(graphBox->lowerQuartile()).arg(graphBox->minimum()).
arg(graphBox->property("StdDev").toDouble()).arg(graphBox->property("avg").toDouble()).
arg(graphBox->property("avgTime").toDouble()),
ui->runPlot, ui->runPlot->rect());
}
}
示例2: mousePress
void smart_plot::mousePress(QMouseEvent *event)
{
static double prevKey, prevValue;
if(event->button() == Qt::MiddleButton)
{
QCPAbstractPlottable *plottable = activePlot()->plottableAt(event->localPos());
if(plottable)
{
QCPGraph *graph = qobject_cast<QCPGraph*>(plottable);
plot_analytics analytics;
plotStats stats;
if(graph)
{
//Do diff by % range vs
double mouseKey = graph->keyAxis()->pixelToCoord(event->localPos().x());
double mouseValue = graph->valueAxis()->pixelToCoord(event->localPos().y());
double keyRange = graph->keyAxis()->range().size();
double keyDistance_no_abs = 0;
double value = 0;
double key = 0;
bool ok = false;
double m = std::numeric_limits<double>::max();
//QCPGraphDataContainer
analytics.plotAnalyze( graph, &stats, graph->keyAxis()->range());
//Iterate through on screen data and see which point is closest
QCPGraphDataContainer::const_iterator QCPGraphDataBegin = graph->data().data()->findBegin(graph->keyAxis()->range().lower,true);
QCPGraphDataContainer::const_iterator QCPGraphDataEnd = graph->data().data()->findEnd(graph->keyAxis()->range().upper,true);
for (QCPGraphDataContainer::const_iterator QCPGraphDataIt=QCPGraphDataBegin; QCPGraphDataIt!=QCPGraphDataEnd; ++QCPGraphDataIt)
{
double valueRange = graph->valueAxis()->range().size();
double keyDistance = qAbs(mouseKey - QCPGraphDataIt->key)/keyRange;
double valueDistance = qAbs(mouseValue - QCPGraphDataIt->value)/valueRange;
if( (valueDistance + keyDistance) < m )
{
value = QCPGraphDataIt->value;
key = QCPGraphDataIt->key;
keyDistance_no_abs = mouseKey - QCPGraphDataIt->key;
ok = true;
m = (valueDistance + keyDistance);
}
}
// qDebug () << QDateTime::fromTime_t((int)mouseKey) << value;
if(ok)
{
QToolTip::hideText();
if(!qSharedPointerDynamicCast<QCPAxisTickerDateTime>(graph->keyAxis()->ticker()).isNull())
{
if(QApplication::keyboardModifiers().testFlag(Qt::ControlModifier))
{
quint32 timeDelta = qAbs(mouseKey-prevKey);
// add the bracket at the top:
QCPItemBracket *bracket = new QCPItemBracket(activePlot());
bracket->left->setAxes(graph->keyAxis(), graph->valueAxis());
bracket->left->setCoords(prevKey, value);
bracket->right->setAxes(graph->keyAxis(), graph->valueAxis());
bracket->right->setCoords(mouseKey, value);
// add the text label at the top:
QCPItemText *wavePacketText = new QCPItemText(activePlot());
wavePacketText->position->setParentAnchor(bracket->center);
wavePacketText->position->setCoords(0, -10); // move 10 pixels to the top from bracket center anchor
wavePacketText->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter);
wavePacketText->setText(
QString("%L1: ΔX->%L2 ΔY->%L3").
arg(graph->name().isEmpty() ? "..." : graph->name()).
arg(seconds_to_DHMS(timeDelta)).
arg(value-prevValue));
wavePacketText->setFont(QFont(font().family(), 12));
activePlot()->replot();
}
else if(QApplication::keyboardModifiers().testFlag(Qt::AltModifier))
{
if(QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier))
graph->addData(graph->keyAxis()->pixelToCoord(event->localPos().x()),
graph->valueAxis()->pixelToCoord(event->localPos().y()));
else if(keyDistance_no_abs < 0)
graph->addData(key - 1, std::numeric_limits<double>::quiet_NaN());
else
graph->addData(key + 1, std::numeric_limits<double>::quiet_NaN());
activePlot()->replot();
}
else if(QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier))
{
//Delete point
graph->data().data()->remove(key);
activePlot()->replot();
}
//Hold Alt to insert NAN(Break link?)
else
{
//.........这里部分代码省略.........