本文整理汇总了C++中QCustomPlot::replot方法的典型用法代码示例。如果您正苦于以下问题:C++ QCustomPlot::replot方法的具体用法?C++ QCustomPlot::replot怎么用?C++ QCustomPlot::replot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCustomPlot
的用法示例。
在下文中一共展示了QCustomPlot::replot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: panAxes
void SequenceDialog::panAxes(int x_pixels, int y_pixels)
{
// We could simplify this quite a bit if we set the scroll bar values instead.
if (!info_->sainfo()) return;
QCustomPlot *sp = ui->sequencePlot;
double h_pan = 0.0;
double v_pan = 0.0;
h_pan = sp->xAxis2->range().size() * x_pixels / sp->xAxis2->axisRect()->width();
if (h_pan < 0) {
h_pan = qMax(h_pan, min_left_ - sp->xAxis2->range().lower);
} else {
h_pan = qMin(h_pan, info_->sainfo()->num_nodes - sp->xAxis2->range().upper);
}
v_pan = sp->yAxis->range().size() * y_pixels / sp->yAxis->axisRect()->height();
if (v_pan < 0) {
v_pan = qMax(v_pan, min_top_ - sp->yAxis->range().lower);
} else {
v_pan = qMin(v_pan, num_items_ - sp->yAxis->range().upper);
}
if (h_pan && !(sp->xAxis2->range().contains(min_left_) && sp->xAxis2->range().contains(info_->sainfo()->num_nodes))) {
sp->xAxis2->moveRange(h_pan);
sp->replot();
}
if (v_pan && !(sp->yAxis->range().contains(min_top_) && sp->yAxis->range().contains(num_items_))) {
sp->yAxis->moveRange(v_pan);
sp->replot();
}
}
示例2: panAxes
void LteRlcGraphDialog::panAxes(int x_pixels, int y_pixels)
{
QCustomPlot *rp = ui->rlcPlot;
double h_pan = 0.0;
double v_pan = 0.0;
// Don't scroll up beyond max range, or below 0
if (((y_pixels > 0) && (rp->yAxis->range().upper > 65536)) ||
((y_pixels < 0) && (rp->yAxis->range().lower < 0))) {
return;
}
// Don't scroll left beyond 0. Arguably should be time of first segment.
if ((x_pixels < 0) && (rp->xAxis->range().lower < 0)) {
return;
}
h_pan = rp->xAxis->range().size() * x_pixels / rp->xAxis->axisRect()->width();
v_pan = rp->yAxis->range().size() * y_pixels / rp->yAxis->axisRect()->height();
// The GTK+ version won't pan unless we're zoomed. Should we do the same here?
if (h_pan) {
rp->xAxis->moveRange(h_pan);
rp->replot(QCustomPlot::rpQueued);
}
if (v_pan) {
rp->yAxis->moveRange(v_pan);
rp->replot(QCustomPlot::rpQueued);
}
}
示例3: resetAxes
void SequenceDialog::resetAxes(bool keep_lower)
{
if (!info_->sainfo()) return;
QCustomPlot *sp = ui->sequencePlot;
// Allow space for labels on the top and port numbers on the left.
double top_pos = min_top_, left_pos = min_left_;
if (keep_lower) {
top_pos = sp->yAxis->range().lower;
left_pos = sp->xAxis2->range().lower;
}
double range_span = sp->viewport().width() / sequence_w_;
sp->xAxis2->setRange(left_pos, range_span + left_pos);
range_span = sp->axisRect()->height() / (one_em_ * 1.5);
sp->yAxis->setRange(top_pos, range_span + top_pos);
double rmin = sp->xAxis2->range().size() / 2;
ui->horizontalScrollBar->setRange((rmin - 0.5) * 100, (info_->sainfo()->num_nodes - 0.5 - rmin) * 100);
xAxisChanged(sp->xAxis2->range());
ui->horizontalScrollBar->setValue(ui->horizontalScrollBar->minimum()); // Shouldn't be needed.
rmin = (sp->yAxis->range().size() / 2);
ui->verticalScrollBar->setRange((rmin - 1.0) * 100, (num_items_ - 0.5 - rmin) * 100);
yAxisChanged(sp->yAxis->range());
// It would be exceedingly handy if we could do one or both of the
// following:
// - Position an axis label above its axis inline with the tick labels.
// - Anchor a QCPItemText to one of the corners of a QCPAxis.
// Neither of those appear to be possible, so we first call replot in
// order to lay out our X axes, place our labels, the call replot again.
sp->replot(QCustomPlot::rpQueued);
QRect axis_rect = sp->axisRect()->rect();
key_text_->position->setCoords(axis_rect.left()
- sp->yAxis->padding()
- sp->yAxis->tickLabelPadding()
- sp->yAxis->offset(),
axis_rect.top() / 2);
comment_text_->position->setCoords(axis_rect.right()
+ sp->yAxis2->padding()
+ sp->yAxis2->tickLabelPadding()
+ sp->yAxis2->offset(),
axis_rect.top() / 2);
sp->replot(QCustomPlot::rpHint);
}
示例4: plotHistogram
void Window::plotHistogram(QVector<double> key, QVector<double> nonEq, QVector<double> eqValue, QVector<double> lutValue)
{
QCustomPlot *histogramPlot = ui->histogramPlot;
histogramPlot->clearGraphs();
// Non Equalized
QCPBars *nonEqHistBars = new QCPBars(histogramPlot->xAxis, histogramPlot->yAxis);
histogramPlot->addPlottable(nonEqHistBars);
nonEqHistBars->setWidth(1);
nonEqHistBars->setData(key, nonEq);
nonEqHistBars->setPen(Qt::NoPen);
nonEqHistBars->setBrush(QColor(10, 140, 70, 160));
// // Equalized
// QCPBars *eqHistBars = new QCPBars(histogramPlot->xAxis, histogramPlot->yAxis);
// histogramPlot->addPlottable(eqHistBars);
// eqHistBars->setWidth(1);
// eqHistBars->setData(key, eqValue);
// eqHistBars->setPen(Qt::NoPen);
// eqHistBars->setBrush(QColor(10, 100, 50, 70));
//// eqHistBars->moveAbove(eqHistBars);
// // LUT
// QCPGraph *lut = histogramPlot->addGraph();
// lut->setData(key, lutValue);
// lut->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone, QPen(Qt::black, 1.5), QBrush(Qt::white), 9));
// lut->setLineStyle(QCPGraph::lsStepCenter);
// lut->setPen(QPen(QColor(120, 120, 120), 2));
histogramPlot->replot();
histogramPlot->rescaleAxes();
}
示例5: zoomYAxis
void LteRlcGraphDialog::zoomYAxis(bool in)
{
QCustomPlot *rp = ui->rlcPlot;
double v_factor = rp->axisRect()->rangeZoomFactor(Qt::Vertical);
if (in) {
// Don't want to zoom in *too* far on y axis.
if (rp->yAxis->range().size() < 10) {
return;
}
}
else {
// Don't want to zoom out *too* far on y axis.
if (rp->yAxis->range().size() > (65536+10)) {
return;
}
}
if (!in) {
v_factor = pow(v_factor, -1);
}
rp->yAxis->scaleRange(v_factor, rp->yAxis->range().center());
rp->replot(QCustomPlot::rpQueued);
}
示例6: resetAxes
void LBMUIMFlowDialog::resetAxes(bool keep_lower)
{
QCustomPlot * sp = m_ui->sequencePlot;
// Allow space for labels on the top and port numbers on the left.
double top_pos = -1.0, left_pos = -0.5;
if (keep_lower)
{
top_pos = sp->yAxis->range().lower;
left_pos = sp->xAxis2->range().lower;
}
double range_ratio = sp->xAxis2->axisRect()->width() / m_node_label_width;
sp->xAxis2->setRange(left_pos, range_ratio + left_pos);
range_ratio = sp->yAxis->axisRect()->height() / (m_one_em * 1.5);
sp->yAxis->setRange(top_pos, range_ratio + top_pos);
double rmin = sp->xAxis2->range().size() / 2;
m_ui->horizontalScrollBar->setRange((rmin - 0.5) * 100, (m_sequence_analysis.num_nodes - 0.5 - rmin) * 100);
xAxisChanged(sp->xAxis2->range());
rmin = (sp->yAxis->range().size() / 2);
m_ui->verticalScrollBar->setRange((rmin - 1.0) * 100, (m_num_items - 0.5 - rmin) * 100);
yAxisChanged(sp->yAxis->range());
sp->replot();
}
示例7: resetAxes
void SequenceDialog::resetAxes(bool keep_lower)
{
if (!sainfo_) return;
QCustomPlot *sp = ui->sequencePlot;
// Allow space for labels on the top and port numbers on the left.
double top_pos = -1.0, left_pos = -0.5;
if (keep_lower) {
top_pos = sp->yAxis->range().lower;
left_pos = sp->xAxis2->range().lower;
}
double range_ratio = sp->xAxis2->axisRect()->width() / node_label_w_;
sp->xAxis2->setRange(left_pos, range_ratio + left_pos);
range_ratio = sp->yAxis->axisRect()->height() / (one_em_ * 1.5);
sp->yAxis->setRange(top_pos, range_ratio + top_pos);
double rmin = sp->xAxis2->range().size() / 2;
ui->horizontalScrollBar->setRange((rmin - 0.5) * 100, (sainfo_->num_nodes - 0.5 - rmin) * 100);
xAxisChanged(sp->xAxis2->range());
rmin = (sp->yAxis->range().size() / 2);
ui->verticalScrollBar->setRange((rmin - 1.0) * 100, (num_items_ - 0.5 - rmin) * 100);
yAxisChanged(sp->yAxis->range());
sp->replot();
}
示例8: addToPlot
void MainWindow::addToPlot(std::vector<double> *x, std::vector<double> *y, int graphNum, AlgorithmFactory::ALGORITHM alg)
{
QCustomPlot *cp = this->ui->plotter;
QVector<double> __x = QVector<double>::fromStdVector(*x);
QVector<double> __y = QVector<double>::fromStdVector(*y);
cp->graph(graphNum)->setData(__x, __y);
switch (alg)
{
default:
case AlgorithmFactory::SPHERE:
cp->graph(graphNum)->setName("Esfera");
break;
case AlgorithmFactory::ROTATED_RASTRIGIN:
cp->graph(graphNum)->setName("Rot Rastrigin");
break;
case AlgorithmFactory::ROSENBROCK:
cp->graph(graphNum)->setName("Rosenbrock");
break;
}
cp->rescaleAxes(true);
cp->replot();
}
示例9: resetAxes
void TCPStreamDialog::resetAxes()
{
QCustomPlot *sp = ui->streamPlot;
y_axis_xfrm_.reset();
double pixel_pad = 10.0; // per side
sp->rescaleAxes(true);
tput_graph_->rescaleValueAxis(false, true);
// base_graph_->rescaleAxes(false, true);
// for (int i = 0; i < sp->graphCount(); i++) {
// sp->graph(i)->rescaleValueAxis(false, true);
// }
double axis_pixels = sp->xAxis->axisRect()->width();
sp->xAxis->scaleRange((axis_pixels + (pixel_pad * 2)) / axis_pixels, sp->xAxis->range().center());
if (sp->yAxis2->visible()) {
double ratio = sp->yAxis2->range().size() / sp->yAxis->range().size();
y_axis_xfrm_.translate(0.0, sp->yAxis2->range().lower - (sp->yAxis->range().lower * ratio));
y_axis_xfrm_.scale(1.0, ratio);
}
axis_pixels = sp->yAxis->axisRect()->height();
sp->yAxis->scaleRange((axis_pixels + (pixel_pad * 2)) / axis_pixels, sp->yAxis->range().center());
sp->replot();
}
示例10: removeAllGraphs
void viewGVpropertieslayout::removeAllGraphs()
{
// first get a pointer to the current plot!
QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget();
currPlot->clearGraphs();
currPlot->replot();
}
示例11: panAxes
void SequenceDialog::panAxes(int x_pixels, int y_pixels)
{
QCustomPlot *sp = ui->sequencePlot;
double h_pan = 0.0;
double v_pan = 0.0;
h_pan = sp->xAxis2->range().size() * x_pixels / sp->xAxis2->axisRect()->width();
v_pan = sp->yAxis->range().size() * y_pixels / sp->yAxis->axisRect()->height();
// The GTK+ version won't pan unless we're zoomed. Should we do the same here?
if (h_pan) {
sp->xAxis2->moveRange(h_pan);
sp->replot();
}
if (v_pan) {
sp->yAxis->moveRange(v_pan);
sp->replot();
}
}
示例12: update
bool TimeseriesGraph::update(const GRT::VectorDouble &sample ){
if( !initialized ) return false;
//Add the new sample to the buffer
data.push_back( sample );
//If the plot is hidden then there is no point in updating the graph
if( this->isHidden() ){
if( !lockRanges ){
//Reset the min and max values
minRange = 99e+99;
maxRange = -minRange;
}
return true;
}
QCustomPlot *plot = ui->graph;
//Clear any previous graphs
plot->clearGraphs();
//Get the data to plot
QVector<double> x( graphWidth );
vector< QVector<double> > y(numDimensions, QVector<double>(graphWidth) );
for (unsigned int i=0; i<graphWidth; i++)
{
x[i] = i;
for(unsigned int j=0; j<numDimensions; j++){
y[j][i] = data[i][j];
if( !lockRanges ){
if( data[i][j] < minRange ) minRange = data[i][j];
else if( data[i][j] > maxRange ) maxRange = data[i][j];
}
}
}
//Create the graphs
for(unsigned int j=0; j<numDimensions; j++){
plot->addGraph();
plot->graph(j)->setPen( QPen( colors[j%colors.size()] ));
plot->graph(j)->setData(x, y[j]);
}
// give the axes some labels:
plot->xAxis->setLabel("Time");
plot->yAxis->setLabel("Values");
// set axes ranges, so we see all data:
plot->xAxis->setRange(0, graphWidth);
plot->yAxis->setRange(minRange, maxRange);
plot->replot();
return true;
}
示例13: removeSelectedGraph
void viewGVpropertieslayout::removeSelectedGraph()
{
// first get a pointer to the current plot!
QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget();
if (currPlot->selectedGraphs().size() > 0)
{
currPlot->removeGraph(currPlot->selectedGraphs().first());
currPlot->replot();
}
}
示例14: on_listView_clicked
void MainWindow::on_listView_clicked(const QModelIndex &index)
{
//QModelIndex a = ui->listView->selectedIndexes().back();
QVariant selected = dataModel->compNameList->data(index,Qt::DisplayRole);
dataModel->dataViewComp = selected.toString();
QVector<double> dataViewPrice = dataModel->priceBuff.value(selected.toString());
QVector<double> xval;
QVector<double> baseVal;
if(dataViewPrice.empty()) return;
double min = dataViewPrice[0];
for(auto &i : dataViewPrice) min = std::fmin(min,i);
for(int i = 0; i<dataViewPrice.size(); i++){
xval<<i;
baseVal<<min;
}
QCustomPlot* p = ui->qcpDataView;;
p->clearGraphs();
QCPGraph* timeline = new QCPGraph(p->xAxis,p->yAxis);
timeline->addData(xval,dataViewPrice);
QCPGraph* base = new QCPGraph(p->xAxis,p->yAxis);
base->setData(xval,baseVal);
p->addPlottable(timeline);
p->addPlottable(base);
timeline->setChannelFillGraph(base);
timeline->setPen(QPen(QColor(0,0,0,0)));
timeline->setBrush(QColor(0,0,255,100));
//QVector<double> ticks;
QVector<QString> labels;
int L = this->dataModel->dateBuff.values()[0].size()-1;
int len = 6;
float step = (float)L/(float)len;
for(int i = 0; i<= len; i++){
labels<<this->dataModel->dateBuff.values()[0][i*step].toString("MM/yy");
}
p->xAxis->setTickVectorLabels(labels);
p->xAxis->setAutoTicks(true);
p->xAxis->setAutoTickLabels(false);
p->xAxis->setTickLabelRotation(-60);
//p->xAxis->setSubTickCount(0);
//p->xAxis->setTickLength(0, len-1);
p->xAxis->grid()->setVisible(true);
//p->xAxis->setRange(0, len-2);
//p->xAxis->setTickVector(ticks);
p->rescaleAxes();
p->replot();
}
示例15: on_rbDay_clicked
void ChartPage::on_rbDay_clicked()
{
ui->rbMonth->setChecked(false);
ui->rbWeek->setChecked(false);
rangeChoice = Day;
QCustomPlot *customPlot = ui->chartBlock;
double mupper = customPlot->xAxis->range().upper;
customPlot->xAxis->setRange(mupper - rangeChoice, mupper);
customPlot->replot();
}