QCustomPlot* Plots::createChart(QVector<double> x, QVector<double> y, QString chartName) { QCustomPlot* customPlot = new QCustomPlot(); // create and configure plottables: QCPBars *bars1 = new QCPBars(customPlot->xAxis, customPlot->yAxis); customPlot->addPlottable(bars1); bars1->setWidth(0.3); bars1->setData(x, y); bars1->setPen(QPen(Qt::red)); bars1->setBrush(QColor(10, 140, 70, 160)); // set title of plot: customPlot->plotLayout()->insertRow(0); customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(customPlot, chartName)); // set a fixed tick-step to one tick per year value: customPlot->xAxis->setAutoTickStep(false); customPlot->xAxis->setTickStep(1); customPlot->xAxis->setSubTickCount(3); // set a fixed tick-step to one tick per колво value: customPlot->yAxis->setAutoTickStep(false); customPlot->yAxis->setTickStep(10); customPlot->yAxis->setSubTickCount(3); // labels customPlot->xAxis->setLabel("Год"); customPlot->yAxis->setLabel("% человек"); customPlot->yAxis->setLabelColor(Qt::white); customPlot->xAxis->setLabelColor(Qt::white); // move bars above graphs and grid below bars: customPlot->addLayer("abovemain", customPlot->layer("main"), QCustomPlot::limAbove); customPlot->addLayer("belowmain", customPlot->layer("main"), QCustomPlot::limBelow); bars1->setLayer("abovemain"); customPlot->xAxis->grid()->setLayer("belowmain"); customPlot->yAxis->grid()->setLayer("belowmain"); // set some pens, brushes and backgrounds: customPlot->xAxis->setBasePen(QPen(Qt::white, 1)); customPlot->yAxis->setBasePen(QPen(Qt::white, 1)); customPlot->xAxis->setTickPen(QPen(Qt::white, 1)); customPlot->yAxis->setTickPen(QPen(Qt::white, 1)); customPlot->xAxis->setSubTickPen(QPen(Qt::white, 1)); customPlot->yAxis->setSubTickPen(QPen(Qt::white, 1)); customPlot->xAxis->setTickLabelColor(Qt::white); customPlot->yAxis->setTickLabelColor(Qt::white); customPlot->xAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine)); customPlot->yAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine)); customPlot->xAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine)); customPlot->yAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine)); customPlot->xAxis->grid()->setSubGridVisible(true); customPlot->yAxis->grid()->setSubGridVisible(true); customPlot->xAxis->grid()->setZeroLinePen(Qt::NoPen); customPlot->yAxis->grid()->setZeroLinePen(Qt::NoPen); customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow); customPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow); QLinearGradient plotGradient; plotGradient.setStart(0, 0); plotGradient.setFinalStop(0, 350); plotGradient.setColorAt(0, QColor(80, 80, 80)); plotGradient.setColorAt(1, QColor(50, 50, 50)); customPlot->setBackground(plotGradient); QLinearGradient axisRectGradient; axisRectGradient.setStart(0, 0); axisRectGradient.setFinalStop(0, 350); axisRectGradient.setColorAt(0, QColor(80, 80, 80)); axisRectGradient.setColorAt(1, QColor(30, 30, 30)); customPlot->axisRect()->setBackground(axisRectGradient); customPlot->rescaleAxes(); customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables); return customPlot; }
void YarrGui::doScan(QString qn){ std::ofstream *tmpOfCout = new std::ofstream("deleteMeCout.txt"); std::streambuf *coutBuf = std::cout.rdbuf(tmpOfCout->rdbuf()); std::ofstream *tmpOfCerr = new std::ofstream("deleteMeCerr.txt"); std::streambuf *cerrBuf = std::cerr.rdbuf(tmpOfCerr->rdbuf()); int N = ui->feTree->topLevelItemCount(); int M = scanVec.size(); for(int j = 0; j < N; j++){ scanDone = false; processorDone = false; if(!(ui->feTree->topLevelItem(j)->child(4)->checkState(1))){continue;} //Is the Scan checkbox checked? Fei4 * fe = dynamic_cast<Fei4*>(bk->feList.at(j)); ScanBase * s = nullptr; if(qn == "NS") {s = new Fei4NoiseScan(bk);} if(qn == "DS") {s = new Fei4DigitalScan(bk);} if(qn == "AS") {s = new Fei4AnalogScan(bk);} if(qn == "TS") {s = new Fei4ThresholdScan(bk);} if(qn == "ToTS") {s = new Fei4TotScan(bk);} if(qn == "GTT") {s = new Fei4GlobalThresholdTune(bk);} if(qn == "GPT") {s = new Fei4GlobalPreampTune(bk);} if(qn == "PTT") {s = new Fei4PixelThresholdTune(bk);} if(qn == "PPT") {s = new Fei4PixelPreampTune(bk);} if(qn == "CS") {s = &cs;} if(s == nullptr){ std::cerr << "Invalid scan QString parameter passed or scan object construction failed. Returning...\n"; return; } QTreeWidgetItem * plotTreeItem = nullptr; //Plot tree item for current FE for(int k = 0; k < ui->plotTree->topLevelItemCount(); k++){ //Is the current FE already in the tree? ... if(ui->plotTree->topLevelItem(k)->text(0) == ui->feTree->topLevelItem(j)->text(0)){ plotTreeItem = ui->plotTree->topLevelItem(k); break; } } if(plotTreeItem == nullptr){ //... if not: create a branch for it plotTreeItem = new QTreeWidgetItem(ui->plotTree); plotTreeItem->setText(0, ui->feTree->topLevelItem(j)->text(0)); } QTreeWidgetItem * plotTreeItemDS = new QTreeWidgetItem(); //plot tree item for current scan plotTreeItemDS->setText(0, qn); plotTreeItem->addChild(plotTreeItemDS); fe->histogrammer = new Fei4Histogrammer(); fe->histogrammer->connect(fe->clipDataFei4, fe->clipHisto); fe->ana = new Fei4Analysis(bk, fe->getRxChannel()); fe->ana->connect(s, fe->clipHisto, fe->clipResult); if (qn=="CS"){ CustomScan * tmp; tmp = dynamic_cast<CustomScan*>(s); if(tmp->bA.at(OCC_MAP) == true) {fe->histogrammer->addHistogrammer(new OccupancyMap());} if(tmp->bA.at(TOT_MAP) == true) {fe->histogrammer->addHistogrammer(new TotMap());} if(tmp->bA.at(TOT_2_MAP) == true) {fe->histogrammer->addHistogrammer(new Tot2Map());} if(tmp->bA.at(OCC_ANA) == true) {fe->ana->addAlgorithm(new OccupancyAnalysis());} if(tmp->bA.at(NOISE_ANA) == true) {fe->ana->addAlgorithm(new NoiseAnalysis());} if(tmp->bA.at(TOT_ANA) == true) {fe->ana->addAlgorithm(new TotAnalysis());} if(tmp->bA.at(S_CU_FIT) == true) {fe->ana->addAlgorithm(new ScurveFitter());} if(tmp->bA.at(PIX_THR) == true) {fe->ana->addAlgorithm(new OccPixelThresholdTune);} }else{ fe->histogrammer->addHistogrammer(new OccupancyMap()); if (qn == "ToTS" || qn == "GPT" || qn == "PPT"){ fe->histogrammer->addHistogrammer(new TotMap()); fe->histogrammer->addHistogrammer(new Tot2Map()); } if(qn == "NS") {fe->ana->addAlgorithm(new NoiseAnalysis());} if(qn == "DS") {fe->ana->addAlgorithm(new OccupancyAnalysis());} if(qn == "AS") {fe->ana->addAlgorithm(new OccupancyAnalysis());} if(qn == "TS") {fe->ana->addAlgorithm(new ScurveFitter());} if(qn == "ToTS") {fe->ana->addAlgorithm(new TotAnalysis());} if(qn == "GTT") {fe->ana->addAlgorithm(new OccGlobalThresholdTune());} if(qn == "GPT") {fe->ana->addAlgorithm(new TotAnalysis());} if(qn == "PTT") {fe->ana->addAlgorithm(new OccPixelThresholdTune());} if(qn == "PPT") {fe->ana->addAlgorithm(new TotAnalysis());} } s->init(); ui->scanProgressBar->setValue(ui->scanProgressBar->value() + (int)(100.0/(7.0*N*M))); //1 s->preScan(); ui->scanProgressBar->setValue(ui->scanProgressBar->value() + (int)(100.0/(7.0*N*M))); //2 unsigned int numThreads = std::thread::hardware_concurrency(); //std::cout << "-> Starting " << numThreads << " processor Threads:" << std::endl; std::vector<std::thread> procThreads; for (unsigned i=0; i<numThreads; i++){ procThreads.push_back(std::thread(process, bk, &scanDone)); //std::cout << " -> Processor thread #" << i << " started!" << std::endl; } std::vector<std::thread> anaThreads; //std::cout << "-> Starting histogrammer and analysis threads:" << std::endl; if (fe->isActive()){ anaThreads.push_back(std::thread(analysis, fe->histogrammer, fe->ana, &processorDone)); //std::cout << " -> Analysis thread of Fe " << fe->getRxChannel() << std::endl; } s->run(); ui->scanProgressBar->setValue(ui->scanProgressBar->value() + (int)(100.0/(7.0*N*M))); //3 s->postScan(); ui->scanProgressBar->setValue(ui->scanProgressBar->value() + (int)(100.0/(7.0*N*M))); //4 scanDone = true; for (unsigned i=0; i<numThreads; i++){ procThreads[i].join(); } ui->scanProgressBar->setValue(ui->scanProgressBar->value() + (int)(100.0/(7.0*N*M))); //5 processorDone = true; for(unsigned i=0; i<anaThreads.size(); i++){ anaThreads[i].join(); } ui->scanProgressBar->setValue(ui->scanProgressBar->value() + (int)(100.0/(7.0*N*M))); //6 if(qn != "CS") { delete s; } // fe->toFileBinary(); // fe->ana->plot("Scan_GUI"); //DEBUG begin [plotting] //clear raw data while(fe->clipDataFei4->size() != 0){ fe->clipDataFei4->popData(); } //clear raw data while(fe->clipHisto->size() != 0){ fe->clipHisto->popData(); } while(fe->clipResult->size() != 0){ HistogramBase * showMe = fe->clipResult->popData(); //Add tab to plot tab widget QCustomPlot * tabScanPlot = new QCustomPlot(ui->scanPlots_tabWidget); // X QWidget * addToTabWidget = dynamic_cast<QWidget*>(tabScanPlot); QString newTabName = qn + ' ' + ui->feTree->topLevelItem(j)->text(0); ui->scanPlots_tabWidget->addTab(addToTabWidget, newTabName); //Add plot to scan tree QTreeWidgetItem * plotTreeItemP = new QTreeWidgetItem(plotTreeItemDS); // X plotTreeItemP->setText(0, "Plot " + QString::number(plotTreeItemDS->childCount()) + " (" + QString::fromStdString(showMe->getName()) + ")"); plotTreeItemDS->addChild(plotTreeItemP); if(dynamic_cast<Histo2d*>(showMe) != nullptr){ Histo2d * myHist2d = dynamic_cast<Histo2d*>(showMe); //Create plot QCPColorMap * colorMap = new QCPColorMap(tabScanPlot->xAxis, tabScanPlot->yAxis); QCPColorScale * colorScale = new QCPColorScale(tabScanPlot); tabScanPlot->addPlottable(colorMap); tabScanPlot->plotLayout()->insertRow(0); tabScanPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(tabScanPlot, QString::fromStdString(myHist2d->getName()))); colorMap->setName(QString::fromStdString(myHist2d->getName())); colorMap->data()->setSize(80, 336); colorMap->data()->setRange(QCPRange(0, 80), QCPRange(0, 336)); colorMap->keyAxis()->setLabel(QString::fromStdString(myHist2d->getXaxisTitle())); colorMap->valueAxis()->setLabel(QString::fromStdString(myHist2d->getYaxisTitle())); for(int xCoord = 0; xCoord<80; xCoord++){ for(int yCoord = 0; yCoord<336; yCoord++){ double colVal = myHist2d->getBin(yCoord + 336*xCoord); //TODO make better colorMap->data()->setCell(xCoord, yCoord, colVal); } } tabScanPlot->plotLayout()->addElement(1, 1, colorScale); colorScale->setType(QCPAxis::atRight); colorMap->setColorScale(colorScale); colorScale->axis()->setLabel(QString::fromStdString(myHist2d->getZaxisTitle())); colorMap->setGradient(QCPColorGradient::gpPolar); colorMap->rescaleDataRange(); }else if(dynamic_cast<Histo1d*>(showMe) != nullptr){ Histo1d * myHist1d = dynamic_cast<Histo1d*>(showMe); QCPBars * myBars = new QCPBars(tabScanPlot->xAxis, tabScanPlot->yAxis); tabScanPlot->addPlottable(myBars); myBars->setName(QString::fromStdString(myHist1d->getName())); for(unsigned int i = 0; i < myHist1d->size(); i++) { myBars->addData((double)(i+1), myHist1d->getBin(i)); } myBars->rescaleAxes(); tabScanPlot->plotLayout()->insertRow(0); tabScanPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(tabScanPlot, QString::fromStdString(myHist1d->getName()))); myBars->keyAxis()->setLabel(QString::fromStdString(myHist1d->getXaxisTitle())); myBars->valueAxis()->setLabel(QString::fromStdString(myHist1d->getYaxisTitle())); }else{ std::cerr << "Correct plot type not found or severe cast error\n"; //DEBUG return; } tabScanPlot->rescaleAxes(); tabScanPlot->replot(); } ui->scanProgressBar->setValue(ui->scanProgressBar->value() + (int)(100.0/(7.0*N*M))); //7 delete fe->histogrammer; fe->histogrammer = nullptr; delete fe->ana; fe->ana = nullptr; } std::cout.rdbuf(coutBuf); std::cerr.rdbuf(cerrBuf); tmpOfCout->close(); tmpOfCerr->close(); std::ifstream tmpInCout("deleteMeCout.txt"); std::ifstream tmpInCerr("deleteMeCerr.txt"); std::cout << tmpInCout.rdbuf(); std::cerr << tmpInCerr.rdbuf(); tmpInCout.close(); tmpInCerr.close(); return; }
void YarrGui::detachPlot(){ if(ui->plotTree->currentItem() == nullptr){ std::cerr << "Please select plot to detach...\n"; return; } if(ui->plotTree->currentItem()->childCount() > 0){ std::cerr << "Please select plot to detach...\n"; return; } PlotDialog * myPDiag = new PlotDialog(); QCustomPlot * plotWidget = dynamic_cast<QCustomPlot*>(ui->scanPlots_tabWidget->currentWidget()); if(plotWidget == nullptr){ std::cerr << "Severe cast error. Aborting...\n"; return; } QCustomPlot * transferPlot = dynamic_cast<QCustomPlot*>(myPDiag->childAt(10, 10)); if(transferPlot == nullptr){ std::cerr << "Severe cast error. Aborting...\n"; return; } QCPPlotTitle * widgetPT = dynamic_cast<QCPPlotTitle*>(plotWidget->plotLayout()->element(0, 0)); if(widgetPT == nullptr){ std::cerr << "Severe cast error. Aborting... \n"; return; } if(dynamic_cast<QCPColorMap*>(plotWidget->plottable(0)) != nullptr){ QCPColorMap * widgetCMap = dynamic_cast<QCPColorMap*>(plotWidget->plottable(0)); QCPColorScale * widgetCScale = dynamic_cast<QCPColorScale*>(plotWidget->plotLayout()->element(1, 1)); if(widgetCScale == nullptr) { std::cerr << "Severe cast error. Aborting... \n"; return; } transferPlot->plotLayout()->insertRow(0); transferPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(transferPlot, widgetPT->text())); QCPColorMap * transferCMap = new QCPColorMap(transferPlot->xAxis, transferPlot->yAxis); transferPlot->addPlottable(transferCMap); transferCMap->data()->setSize(80, 336); transferCMap->setData(widgetCMap->data(), true); QCPColorScale * transferCScale = new QCPColorScale(transferPlot); transferPlot->plotLayout()->addElement(1, 1, transferCScale); transferCScale->setType(QCPAxis::atRight); transferCMap->setColorScale(transferCScale); transferCMap->keyAxis()->setLabel(widgetCMap->keyAxis()->label()); transferCMap->valueAxis()->setLabel(widgetCMap->valueAxis()->label()); transferCScale->axis()->setLabel(widgetCScale->axis()->label()); transferCMap->setGradient(QCPColorGradient::gpPolar); transferCMap->rescaleDataRange(); }else if(dynamic_cast<QCPBars*>(plotWidget->plottable(0)) != nullptr){ QCPBars * widgetBars = dynamic_cast<QCPBars*>(plotWidget->plottable(0)); QCPBars * transferBars = new QCPBars(transferPlot->xAxis, transferPlot->yAxis); transferBars->setData(widgetBars->data(), true); transferBars->rescaleAxes(); transferPlot->plotLayout()->insertRow(0); transferPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(transferPlot, widgetPT->text())); transferBars->keyAxis()->setLabel(widgetBars->keyAxis()->label()); transferBars->valueAxis()->setLabel(widgetBars->valueAxis()->label()); }else{ std::cerr << "Severe cast error. Aborting... \n"; //DEBUG return; } transferPlot->rescaleAxes(); transferPlot->replot(); myPDiag->setModal(false); myPDiag->show(); removePlot(); return; }
TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_type graph_type) : QDialog(NULL, Qt::Window), ui(new Ui::TCPStreamDialog), cap_file_(cf), ts_offset_(0), ts_origin_conn_(true), seq_offset_(0), seq_origin_zero_(true), title_(NULL), base_graph_(NULL), tput_graph_(NULL), seg_graph_(NULL), ack_graph_(NULL), rwin_graph_(NULL), tracer_(NULL), packet_num_(0), mouse_drags_(true), rubber_band_(NULL), num_dsegs_(-1), num_acks_(-1), num_sack_ranges_(-1) { struct segment current; int graph_idx = -1; ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); graph_.type = GRAPH_UNDEFINED; set_address(&graph_.src_address, AT_NONE, 0, NULL); graph_.src_port = 0; set_address(&graph_.dst_address, AT_NONE, 0, NULL); graph_.dst_port = 0; graph_.stream = 0; graph_.segments = NULL; struct tcpheader *header = select_tcpip_session(cap_file_, ¤t); if (!header) { done(QDialog::Rejected); return; } //#ifdef Q_OS_MAC // ui->hintLabel->setAttribute(Qt::WA_MacSmallSize, true); //#endif QComboBox *gtcb = ui->graphTypeComboBox; gtcb->setUpdatesEnabled(false); gtcb->addItem(ui->actionRoundTripTime->text(), GRAPH_RTT); if (graph_type == GRAPH_RTT) graph_idx = gtcb->count() - 1; gtcb->addItem(ui->actionThroughput->text(), GRAPH_THROUGHPUT); if (graph_type == GRAPH_THROUGHPUT) graph_idx = gtcb->count() - 1; gtcb->addItem(ui->actionStevens->text(), GRAPH_TSEQ_STEVENS); if (graph_type == GRAPH_TSEQ_STEVENS) graph_idx = gtcb->count() - 1; gtcb->addItem(ui->actionTcptrace->text(), GRAPH_TSEQ_TCPTRACE); if (graph_type == GRAPH_TSEQ_TCPTRACE) graph_idx = gtcb->count() - 1; gtcb->addItem(ui->actionWindowScaling->text(), GRAPH_WSCALE); if (graph_type == GRAPH_WSCALE) graph_idx = gtcb->count() - 1; gtcb->setUpdatesEnabled(true); ui->dragRadioButton->setChecked(mouse_drags_); ctx_menu_.addAction(ui->actionZoomIn); ctx_menu_.addAction(ui->actionZoomInX); ctx_menu_.addAction(ui->actionZoomInY); ctx_menu_.addAction(ui->actionZoomOut); ctx_menu_.addAction(ui->actionZoomOutX); ctx_menu_.addAction(ui->actionZoomOutY); ctx_menu_.addAction(ui->actionReset); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionMoveRight10); ctx_menu_.addAction(ui->actionMoveLeft10); ctx_menu_.addAction(ui->actionMoveUp10); ctx_menu_.addAction(ui->actionMoveDown10); ctx_menu_.addAction(ui->actionMoveRight1); ctx_menu_.addAction(ui->actionMoveLeft1); ctx_menu_.addAction(ui->actionMoveUp1); ctx_menu_.addAction(ui->actionMoveDown1); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionNextStream); ctx_menu_.addAction(ui->actionPreviousStream); ctx_menu_.addAction(ui->actionSwitchDirection); ctx_menu_.addAction(ui->actionGoToPacket); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionDragZoom); ctx_menu_.addAction(ui->actionToggleSequenceNumbers); ctx_menu_.addAction(ui->actionToggleTimeOrigin); ctx_menu_.addAction(ui->actionCrosshairs); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionRoundTripTime); ctx_menu_.addAction(ui->actionThroughput); ctx_menu_.addAction(ui->actionStevens); ctx_menu_.addAction(ui->actionTcptrace); ctx_menu_.addAction(ui->actionWindowScaling); memset (&graph_, 0, sizeof(graph_)); graph_.type = graph_type; copy_address(&graph_.src_address, ¤t.ip_src); graph_.src_port = current.th_sport; copy_address(&graph_.dst_address, ¤t.ip_dst); graph_.dst_port = current.th_dport; graph_.stream = header->th_stream; findStream(); ui->streamNumberSpinBox->blockSignals(true); ui->streamNumberSpinBox->setMaximum(get_tcp_stream_count() - 1); ui->streamNumberSpinBox->setValue(graph_.stream); ui->streamNumberSpinBox->blockSignals(false); QCustomPlot *sp = ui->streamPlot; QCPPlotTitle *file_title = new QCPPlotTitle(sp, cf_get_display_name(cap_file_)); file_title->setFont(sp->xAxis->labelFont()); title_ = new QCPPlotTitle(sp); sp->plotLayout()->insertRow(0); sp->plotLayout()->addElement(0, 0, file_title); sp->plotLayout()->insertRow(0); sp->plotLayout()->addElement(0, 0, title_); base_graph_ = sp->addGraph(); // All: Selectable segments base_graph_->setPen(QPen(QBrush(graph_color_1), 0.25)); tput_graph_ = sp->addGraph(sp->xAxis, sp->yAxis2); // Throughput: Moving average tput_graph_->setPen(QPen(QBrush(graph_color_2), 0.5)); tput_graph_->setLineStyle(QCPGraph::lsLine); seg_graph_ = sp->addGraph(); // tcptrace: fwd segments seg_graph_->setErrorType(QCPGraph::etValue); seg_graph_->setLineStyle(QCPGraph::lsNone); seg_graph_->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDot, Qt::transparent, 0)); seg_graph_->setErrorPen(QPen(QBrush(graph_color_1), 0.5)); seg_graph_->setErrorBarSize(pkt_point_size_); ack_graph_ = sp->addGraph(); // tcptrace: rev ACKs ack_graph_->setPen(QPen(QBrush(graph_color_2), 0.5)); ack_graph_->setLineStyle(QCPGraph::lsStepLeft); rwin_graph_ = sp->addGraph(); // tcptrace: rev RWIN rwin_graph_->setPen(QPen(QBrush(graph_color_3), 0.5)); rwin_graph_->setLineStyle(QCPGraph::lsStepLeft); tracer_ = new QCPItemTracer(sp); sp->addItem(tracer_); // Triggers fillGraph(). ui->graphTypeComboBox->setCurrentIndex(graph_idx); sp->setMouseTracking(true); sp->yAxis->setLabelColor(QColor(graph_color_1)); sp->yAxis->setTickLabelColor(QColor(graph_color_1)); tracer_->setVisible(false); toggleTracerStyle(true); QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS)); QPushButton *close_bt = ui->buttonBox->button(QDialogButtonBox::Close); if (close_bt) { close_bt->setDefault(true); } ProgressFrame::addToButtonBox(ui->buttonBox, parent); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*))); connect(sp, SIGNAL(axisClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisClicked(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(transformYRange(QCPRange))); disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); this->setResult(QDialog::Accepted); }