MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setupPlot(); // configure scroll bars: // Since scroll bars only support integer values, we'll set a high default range of -500..500 and // divide scroll bar position values by 100 to provide a scroll range -5..5 in floating point // axis coordinates. if you want to dynamically grow the range accessible with the scroll bar, // just increase the the minimum/maximum values of the scroll bars as needed. ui->horizontalScrollBar->setRange(-500, 500); ui->verticalScrollBar->setRange(-500, 500); // create connection between axes and scroll bars: connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horzScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vertScrollBarChanged(int))); connect(ui->plot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(ui->plot->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); // initialize axis range (and scroll bar positions via signals we just connected): ui->plot->xAxis->setRange(0, 6, Qt::AlignCenter); ui->plot->yAxis->setRange(0, 10, Qt::AlignCenter); }
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(); }
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(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // configurate scrollbars ui->horizontalScrollBar->setRange(-410, -290); ui->verticalScrollBar->setRange(-1300, -1240); // create connection between axes and scroll bars: connect(ui->widget->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(ui->widget->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); // initialize axis range und zooming ui->widget->xAxis->setRange(-4.1, -3.2, Qt::AlignCenter); ui->widget->yAxis->setRange(12.4, 13, Qt::AlignCenter); ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); // draw routes by selecting table row connect(ui->tableWidget_weekplans, SIGNAL(cellClicked(int, int)), this, SLOT(weekSelected(int, int))); connect(ui->tableWidget_dayplans, SIGNAL(cellClicked(int, int)), this, SLOT(daySelected(int, int))); // table of week plans ui->tableWidget_weekplans->setRowCount(constant::nweeks * constant::P); ui->tableWidget_weekplans->setColumnCount(3); QStringList Header; Header << "Work time" << "#Villages" << "#Households"; ui->tableWidget_weekplans->setHorizontalHeaderLabels(Header); ui->tableWidget_weekplans->setColumnWidth(0,80); ui->tableWidget_weekplans->setColumnWidth(1,80); ui->tableWidget_weekplans->setColumnWidth(2,100); // table of day plans ui->tableWidget_dayplans->setRowCount(5); ui->tableWidget_dayplans->setColumnCount(5); Header.clear(); Header << "Day" << "Villages" << "#Hh" << "Househols" << "Itime" << "Ttime" << "Wtime"; ui->tableWidget_dayplans->setHorizontalHeaderLabels(Header); ui->tableWidget_dayplans->setColumnWidth(0,30); ui->tableWidget_dayplans->setColumnWidth(1,100); ui->tableWidget_dayplans->setColumnWidth(2,30); ui->tableWidget_dayplans->setColumnWidth(3,130); ui->tableWidget_dayplans->setColumnWidth(4,50); // show report window connect(ui->pbShow_report, SIGNAL(clicked()), this, SLOT(showReportWindow())); // default file selection MainWindow::on_buttonOpenVillages_clicked(); MainWindow::on_buttonOpenRoads_clicked(); MainWindow::on_buttonOpenHouseh_clicked(); }
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); }
ChartPage::ChartPage(QWidget *parent) : QWidget(parent), clientModel(0), lastBlockHeight(0), rangeChoice(Day), ui(new Ui::ChartPage) { ui->setupUi(this); ui->hSlider->setVisible(false); ui->vSlider->setVisible(false); ui->verticalScrollBar->setVisible(false); ui->horizontalScrollBar->setVisible(false); setupChart(); // configure scroll bars: // Since scroll bars only support integer values, we'll set a high default range of and // divide or multiply scroll bar position values to achieve corrected axeis coordinates. ui->horizontalScrollBar->setRange(-1, 500000); ui->verticalScrollBar->setRange(500, -1); // create connection between axes and scroll bars: connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horzScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vertScrollBarChanged(int))); connect(ui->chartBlock->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(ui->chartBlock->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(addChartPoints())); timer->start(100); }
PlotItemDialog::PlotItemDialog(PlotItem *item, QWidget *parent) : ViewItemDialog(item, parent), _plotItem(item), _defaultTagString("<Auto Name>") { Q_ASSERT(_plotItem); _store = kstApp->mainWindow()->document()->objectStore(); setWindowTitle(tr("Edit Plot Item")); _contentTab = new ContentTab(this, _store); connect(_contentTab, SIGNAL(apply()), this, SLOT(contentChanged())); DialogPage *contentsPage = new DialogPage(this); contentsPage->setPageTitle(tr("Contents")); contentsPage->addDialogTab(_contentTab); addDialogPage(contentsPage, true); _labelTab = new LabelTab(_plotItem, this); _topLabelTab = new OverrideLabelTab(tr("Top Font"), this); _bottomLabelTab = new OverrideLabelTab(tr("Bottom Font"), this); _leftLabelTab = new OverrideLabelTab(tr("Left Font"), this); _rightLabelTab = new OverrideLabelTab(tr("Right Font"), this); _axisLabelTab = new OverrideLabelTab(tr("Axis Font"), this); _labelPage = new DialogPageTab(this); _labelPage->setPageTitle(tr("Labels")); _labelPage->addDialogTab(_labelTab); _labelPage->addDialogTab(_topLabelTab); _labelPage->addDialogTab(_bottomLabelTab); _labelPage->addDialogTab(_leftLabelTab); _labelPage->addDialogTab(_rightLabelTab); _labelPage->addDialogTab(_axisLabelTab); addDialogPage(_labelPage, true); connect(_labelTab, SIGNAL(apply()), this, SLOT(labelsChanged())); connect(_labelTab, SIGNAL(globalFontUpdate()), this, SLOT(globalFontUpdate())); connect(_topLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useTopDefaultChanged(bool))); connect(_bottomLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useBottomDefaultChanged(bool))); connect(_leftLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useLeftDefaultChanged(bool))); connect(_rightLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useRightDefaultChanged(bool))); connect(_axisLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useAxisDefaultChanged(bool))); _rangeTab = new RangeTab(_plotItem, this); DialogPage *rangePage = new DialogPage(this); rangePage->setPageTitle(tr("Range/Zoom")); rangePage->addDialogTab(_rangeTab); addDialogPage(rangePage, true); connect(_rangeTab, SIGNAL(apply()), this, SLOT(rangeChanged())); _xAxisTab = new AxisTab(this); _xAxisPage = new DialogPage(this); _xAxisPage->setPageTitle(tr("X-Axis")); _xAxisPage->addDialogTab(_xAxisTab); addDialogPage(_xAxisPage, true); connect(_xAxisTab, SIGNAL(apply()), this, SLOT(xAxisChanged())); _yAxisTab = new AxisTab(this); _yAxisTab->setAsYAxis(); _yAxisPage = new DialogPage(this); _yAxisPage->setPageTitle(tr("Y-Axis")); _yAxisPage->addDialogTab(_yAxisTab); addDialogPage(_yAxisPage, true); connect(_yAxisTab, SIGNAL(apply()), this, SLOT(yAxisChanged())); _xMarkersTab = new MarkersTab(this); DialogPage *xMarkersPage = new DialogPage(this); xMarkersPage->setPageTitle(tr("X-Axis Markers")); xMarkersPage->addDialogTab(_xMarkersTab); addDialogPage(xMarkersPage, true); _xMarkersTab->setObjectStore(_store); connect(_xMarkersTab, SIGNAL(apply()), this, SLOT(xAxisPlotMarkersChanged())); _yMarkersTab = new MarkersTab(this); DialogPage *yMarkersPage = new DialogPage(this); yMarkersPage->setPageTitle(tr("Y-Axis Markers")); yMarkersPage->addDialogTab(_yMarkersTab); addDialogPage(yMarkersPage, true); _yMarkersTab->setObjectStore(_store); connect(yMarkersPage, SIGNAL(apply()), this, SLOT(yAxisPlotMarkersChanged())); // addRelations(); This tends to clutter the plot dialog, let's test skipping it setupContent(); setupAxis(); setupRange(); setupLabels(); setupMarkers(); setSupportsMultipleEdit(true); if (_plotItem->descriptiveNameIsManual()) { setTagString(_plotItem->descriptiveName()); } else { setTagString(_defaultTagString); } QList<PlotItem*> list = ViewItem::getItems<PlotItem>(); clearMultipleEditOptions(); foreach(PlotItem* plot, list) { addMultipleEditOption(plot->plotName(), plot->descriptionTip(), plot->shortName()); }
AP2DataPlot2D::AP2DataPlot2D(QWidget *parent) : QWidget(parent), m_uas(NULL), m_logDownloadDialog(NULL), m_updateTimer(NULL), m_tlogReplayEnabled(false) { m_startIndex = 0; m_axisGroupingDialog = 0; m_logLoaderThread= 0; m_logLoaded = false; m_progressDialog=0; m_currentIndex=0; m_graphCount=0; m_showOnlyActive = false; ui.setupUi(this); QDateTime utc = QDateTime::currentDateTimeUtc(); utc.setTimeSpec(Qt::LocalTime); m_timeDiff = QDateTime::currentDateTime().msecsTo(utc); m_plot = new QCustomPlot(ui.widget); m_plot->setInteraction(QCP::iRangeDrag, true); m_plot->setInteraction(QCP::iRangeZoom, true); connect(m_plot,SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)),this,SLOT(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*))); connect(m_plot,SIGNAL(mouseMove(QMouseEvent*)),this,SLOT(plotMouseMove(QMouseEvent*))); //ui.horizontalLayout_3->addWidget(m_plot); ui.verticalLayout_5->insertWidget(0,m_plot); m_plot->show(); m_plot->plotLayout()->clear(); m_wideAxisRect = new QCPAxisRect(m_plot); m_wideAxisRect->setupFullAxesBox(true); m_wideAxisRect->axis(QCPAxis::atRight, 0)->setTickLabels(false); m_wideAxisRect->removeAxis(m_wideAxisRect->axis(QCPAxis::atLeft,0)); m_wideAxisRect->axis(QCPAxis::atBottom, 0)->setTickLabelType(QCPAxis::ltDateTime); m_wideAxisRect->axis(QCPAxis::atBottom, 0)->setDateTimeFormat("hh:mm:ss"); m_wideAxisRect->axis(QCPAxis::atBottom, 0)->setRange(m_timeDiff / 1000,(m_timeDiff / 1000) + 100); //Default range of 0-100 milliseconds? m_plot->plotLayout()->addElement(0, 0, m_wideAxisRect); QCPMarginGroup *marginGroup = new QCPMarginGroup(m_plot); m_wideAxisRect->setMarginGroup(QCP::msLeft | QCP::msRight, marginGroup); m_dataSelectionScreen = new DataSelectionScreen(this); connect( m_dataSelectionScreen,SIGNAL(itemEnabled(QString)),this,SLOT(itemEnabled(QString))); connect( m_dataSelectionScreen,SIGNAL(itemDisabled(QString)),this,SLOT(itemDisabled(QString))); ui.horizontalLayout_3->addWidget(m_dataSelectionScreen); ui.horizontalLayout_3->setStretch(0,5); ui.horizontalLayout_3->setStretch(1,1); connect(UASManager::instance(),SIGNAL(activeUASSet(UASInterface*)),this,SLOT(activeUASSet(UASInterface*))); activeUASSet(UASManager::instance()->getActiveUAS()); ui.tableWidget->setContextMenuPolicy(Qt::ActionsContextMenu); m_addGraphAction = new QAction("Add To Graph",0); ui.tableWidget->addAction(m_addGraphAction); connect(m_addGraphAction,SIGNAL(triggered()),this,SLOT(addGraphLeft())); ui.tableWidget->setVisible(false); ui.hideExcelView->setVisible(false); connect(ui.loadOfflineLogButton,SIGNAL(clicked()),this,SLOT(loadButtonClicked())); connect(ui.autoScrollCheckBox,SIGNAL(clicked(bool)),this,SLOT(autoScrollClicked(bool))); connect(ui.hideExcelView,SIGNAL(clicked(bool)),ui.tableWidget,SLOT(setHidden(bool))); connect(ui.tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(tableCellClicked(int,int))); ui.logTypeLabel->setText("<p align=\"center\"><span style=\" font-size:24pt; color:#0000ff;\">Live Data</span></p>"); connect(ui.graphControlsPushButton,SIGNAL(clicked()),this,SLOT(graphControlsButtonClicked())); model = new QStandardItemModel(); connect(ui.toKMLPushButton, SIGNAL(clicked()), this, SIGNAL(toKMLClicked())); connect(ui.horizontalScrollBar,SIGNAL(sliderMoved(int)),this,SLOT(horizontalScrollMoved(int))); connect(ui.verticalScrollBar,SIGNAL(sliderMoved(int)),this,SLOT(verticalScrollMoved(int))); connect(ui.horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horizontalScrollMoved(int))); connect(ui.verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(verticalScrollMoved(int))); connect(m_wideAxisRect->axis(QCPAxis::atBottom), SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); m_plot->setPlottingHint(QCP::phFastPolylines,true); connect(ui.downloadPushButton, SIGNAL(clicked()), this, SLOT(showLogDownloadDialog())); ui.downloadPushButton->setEnabled(false); connect(ui.loadTLogButton,SIGNAL(clicked()),this,SLOT(replyTLogButtonClicked())); }
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, seq_analysis_info_t *sainfo) : WiresharkDialog(parent, cf), ui(new Ui::SequenceDialog), sainfo_(sainfo), num_items_(0), packet_num_(0), node_label_w_(20) { ui->setupUi(this); QCustomPlot *sp = ui->sequencePlot; setWindowSubtitle(sainfo ? tr("Call Flow") : tr("Flow")); if (!sainfo_) { sainfo_ = sequence_analysis_info_new(); sainfo_->type = SEQ_ANALYSIS_ANY; sainfo_->all_packets = TRUE; } else { num_items_ = sequence_analysis_get_nodes(sainfo_); } seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2); sp->addPlottable(seq_diagram_); sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis); sp->xAxis->setVisible(false); sp->xAxis->setPadding(0); sp->xAxis->setLabelPadding(0); sp->xAxis->setTickLabelPadding(0); sp->xAxis2->setVisible(true); sp->yAxis2->setVisible(true); one_em_ = QFontMetrics(sp->yAxis->labelFont()).height(); ui->horizontalScrollBar->setSingleStep(100 / one_em_); ui->verticalScrollBar->setSingleStep(100 / one_em_); sp->setInteractions(QCP::iRangeDrag); ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); 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->actionGoToPacket); ui->showComboBox->blockSignals(true); ui->showComboBox->setCurrentIndex(0); ui->showComboBox->blockSignals(false); ui->addressComboBox->blockSignals(true); ui->addressComboBox->setCurrentIndex(0); ui->addressComboBox->blockSignals(false); QComboBox *fcb = ui->flowComboBox; fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY); fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP); ui->flowComboBox->blockSignals(true); ui->flowComboBox->setCurrentIndex(sainfo_->type); if (sainfo_->type == SEQ_ANALYSIS_VOIP) { ui->controlFrame->hide(); } else { ui->flowComboBox->blockSignals(false); } QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS)); // XXX Use recent settings instead resize(parent.width(), parent.height() * 4 / 5); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int))); connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*))); connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int))); disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); fillDiagram(); }
SequenceDialog::SequenceDialog(QWidget *parent, capture_file *cf, SequenceType type) : QDialog(parent), ui(new Ui::SequenceDialog), cap_file_(cf), num_items_(0), packet_num_(0), node_label_w_(20) { ui->setupUi(this); QCustomPlot *sp = ui->sequencePlot; seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2); sp->addPlottable(seq_diagram_); sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis); sp->xAxis->setVisible(false); sp->xAxis->setPadding(0); sp->xAxis->setLabelPadding(0); sp->xAxis->setTickLabelPadding(0); sp->xAxis2->setVisible(true); sp->yAxis2->setVisible(true); one_em_ = QFontMetrics(sp->yAxis->labelFont()).height(); ui->horizontalScrollBar->setSingleStep(100 / one_em_); ui->verticalScrollBar->setSingleStep(100 / one_em_); sp->setInteractions(QCP::iRangeDrag); ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); 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->actionGoToPacket); memset (&seq_analysis_, 0, sizeof(seq_analysis_)); ui->showComboBox->blockSignals(true); ui->showComboBox->setCurrentIndex(0); ui->showComboBox->blockSignals(false); ui->addressComboBox->blockSignals(true); ui->addressComboBox->setCurrentIndex(0); ui->addressComboBox->blockSignals(false); QComboBox *fcb = ui->flowComboBox; fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY); fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP); ui->flowComboBox->blockSignals(true); switch (type) { case any: seq_analysis_.type = SEQ_ANALYSIS_ANY; ui->flowComboBox->setCurrentIndex(SEQ_ANALYSIS_ANY); break; case tcp: seq_analysis_.type = SEQ_ANALYSIS_TCP; ui->flowComboBox->setCurrentIndex(SEQ_ANALYSIS_TCP); break; case voip: seq_analysis_.type = SEQ_ANALYSIS_VOIP; ui->flowComboBox->hide(); ui->flowLabel->hide(); break; } ui->flowComboBox->blockSignals(false); seq_analysis_.all_packets = TRUE; QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As...")); // XXX Use recent settings instead if (parent) { resize(parent->width(), parent->height() * 4 / 5); } connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int))); connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*))); connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int))); disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); fillDiagram(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), settings(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QDir::separator() + "settings.ini", QSettings::IniFormat), first(true), started(true) { srand(QDateTime::currentDateTime().toTime_t()); ui->setupUi(this); ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables); // Axes ui->customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime); ui->customPlot->xAxis->setDateTimeFormat("hh:mm:ss"); ui->customPlot->xAxis->setAutoTickStep(false); ui->customPlot->xAxis->setTickStep(2); ui->customPlot->xAxis->setLabel("Time"); ui->customPlot->xAxis->setLabelPadding(0); ui->customPlot->xAxis->setSelectableParts(QCPAxis::spAxis); ui->customPlot->yAxis->setRange(-20, 20); ui->customPlot->yAxis->setLabel("Acceleration (m/s^2)"); ui->customPlot->yAxis->setLabelPadding(0); ui->customPlot->yAxis->setSelectableParts(QCPAxis::spAxis); ui->customPlot->axisRect()->setupFullAxesBox(); // Legend ui->customPlot->legend->setVisible(true); QFont legendFont = font(); legendFont.setPointSize(10); ui->customPlot->legend->setFont(legendFont); ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectableParts(QCPLegend::spNone); // X, Y, Z reading graphs ui->customPlot->addGraph(); // blue line ui->customPlot->graph(0)->setPen(QPen(Qt::blue)); ui->customPlot->graph(0)->setName("X"); ui->customPlot->graph(0)->setSelectable(false); ui->customPlot->addGraph(); // red line ui->customPlot->graph(1)->setPen(QPen(Qt::red)); ui->customPlot->graph(1)->setName("Y"); ui->customPlot->graph(1)->setSelectable(false); ui->customPlot->addGraph(); // green line ui->customPlot->graph(2)->setPen(QPen(Qt::green)); ui->customPlot->graph(2)->setName("Z"); ui->customPlot->graph(2)->setSelectable(false); // Scale in a particular direction when an axis is selected connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress())); connect(ui->customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel())); // Make bottom and left axes transfer their ranges to top and right axes: connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange))); connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange))); // Adjust the tick marks on x-axis scale connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); // Context menu popup ui->customPlot->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->customPlot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint))); // Buttons connect(ui->buttonStartStop, SIGNAL(released()), this, SLOT(pressedStartStop())); connect(ui->buttonAnalyze, SIGNAL(released()), this, SLOT(pressedAnalyze())); connect(ui->buttonSave, SIGNAL(released()), this, SLOT(pressedSave())); // Setup accelerometer accelerometer = new QAccelerometer(this); accelerometer->setAccelerationMode(QAccelerometer::Combined); accelerometer->setDataRate(30); accelerometer->addFilter(&filter); // We'll always keep it running since on the phone apparently calling // stop makes the whole application freeze. Thus, we'll just start/stop // recording data not actually requesting data from the accelerometer accelerometer->start(); // Button enabled/disabled coloring button_enabled = ui->buttonStartStop->palette(); button_disabled = ui->buttonStartStop->palette(); button_enabled.setColor(QPalette::Button, QColor(Qt::white)); button_disabled.setColor(QPalette::Button, QColor(Qt::lightGray)); // Load previous settings bool timed = settings.value("timed").toBool(); ui->checkBoxTimed->setChecked(timed); // When we start the application, either start it automatically if we're // not using a fixed period of time or set it up so we can press Start to // start it if we are using a fixed period of time if (timed) stop(); else start(); // Setup a timer that repeatedly calls MainWindow::realtimeDataSlot connect(&dataTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot())); // Stop it after a certain period of time connect(&finishTimer, SIGNAL(timeout()), this, SLOT(finishSlot())); // Start with delay to reduce effect of touching the "Start" // button when recording for set amount of time connect(&startTimer, SIGNAL(timeout()), this, SLOT(startSlot())); }
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info) : WiresharkDialog(parent, cf), ui(new Ui::SequenceDialog), info_(info), num_items_(0), packet_num_(0), sequence_w_(1) { ui->setupUi(this); loadGeometry(parent.width(), parent.height() * 4 / 5); QCustomPlot *sp = ui->sequencePlot; setWindowSubtitle(info_ ? tr("Call Flow") : tr("Flow")); if (!info_) { info_ = new SequenceInfo(sequence_analysis_info_new()); info_->sainfo()->type = SEQ_ANALYSIS_ANY; info_->sainfo()->all_packets = TRUE; } else { info_->ref(); num_items_ = sequence_analysis_get_nodes(info_->sainfo()); } seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2); sp->addPlottable(seq_diagram_); // When dragging is enabled it's easy to drag past the lower and upper // bounds of each axis. Disable it for now. //sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis); //sp->setInteractions(QCP::iRangeDrag); sp->xAxis->setVisible(false); sp->xAxis->setPadding(0); sp->xAxis->setLabelPadding(0); sp->xAxis->setTickLabelPadding(0); QPen base_pen(ColorUtils::alphaBlend(palette().text(), palette().base(), 0.25)); base_pen.setWidthF(0.5); sp->xAxis2->setBasePen(base_pen); sp->yAxis->setBasePen(base_pen); sp->yAxis2->setBasePen(base_pen); sp->xAxis2->setVisible(true); sp->yAxis2->setVisible(true); key_text_ = new QCPItemText(sp); key_text_->setText(tr("Time")); sp->addItem(key_text_); key_text_->setPositionAlignment(Qt::AlignRight | Qt::AlignVCenter); key_text_->position->setType(QCPItemPosition::ptAbsolute); key_text_->setClipToAxisRect(false); comment_text_ = new QCPItemText(sp); comment_text_->setText(tr("Comment")); sp->addItem(comment_text_); comment_text_->setPositionAlignment(Qt::AlignLeft | Qt::AlignVCenter); comment_text_->position->setType(QCPItemPosition::ptAbsolute); comment_text_->setClipToAxisRect(false); one_em_ = QFontMetrics(sp->yAxis->labelFont()).height(); ui->horizontalScrollBar->setSingleStep(100 / one_em_); ui->verticalScrollBar->setSingleStep(100 / one_em_); ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); 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->actionGoToPacket); ctx_menu_.addAction(ui->actionGoToNextPacket); ctx_menu_.addAction(ui->actionGoToPreviousPacket); ui->showComboBox->setCurrentIndex(0); ui->addressComboBox->setCurrentIndex(0); QComboBox *fcb = ui->flowComboBox; fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY); fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP); ui->flowComboBox->setCurrentIndex(info_->sainfo()->type); if (info_->sainfo()->type == SEQ_ANALYSIS_VOIP) { ui->flowComboBox->blockSignals(true); ui->controlFrame->hide(); } QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS)); ProgressFrame::addToButtonBox(ui->buttonBox, &parent); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int))); connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheeled(QWheelEvent*))); connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int))); disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); }
LBMUIMFlowDialog::LBMUIMFlowDialog(QWidget * parent, capture_file * cfile) : QDialog(parent), m_ui(new Ui::LBMUIMFlowDialog), m_capture_file(cfile), m_num_items(0), m_packet_num(0), m_node_label_width(20) { m_ui->setupUi(this); QCustomPlot * sp = m_ui->sequencePlot; m_sequence_diagram = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2); sp->addPlottable(m_sequence_diagram); sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis); sp->xAxis->setVisible(false); sp->xAxis->setPadding(0); sp->xAxis->setLabelPadding(0); sp->xAxis->setTickLabelPadding(0); sp->xAxis2->setVisible(true); sp->yAxis2->setVisible(true); m_one_em = QFontMetrics(sp->yAxis->labelFont()).height(); m_ui->horizontalScrollBar->setSingleStep(100 / m_one_em); m_ui->verticalScrollBar->setSingleStep(100 / m_one_em); sp->setInteractions(QCP::iRangeDrag); m_ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); m_context_menu.addAction(m_ui->actionReset); m_context_menu.addSeparator(); m_context_menu.addAction(m_ui->actionMoveRight10); m_context_menu.addAction(m_ui->actionMoveLeft10); m_context_menu.addAction(m_ui->actionMoveUp10); m_context_menu.addAction(m_ui->actionMoveDown10); m_context_menu.addAction(m_ui->actionMoveRight1); m_context_menu.addAction(m_ui->actionMoveLeft1); m_context_menu.addAction(m_ui->actionMoveUp1); m_context_menu.addAction(m_ui->actionMoveDown1); m_context_menu.addSeparator(); m_context_menu.addAction(m_ui->actionGoToPacket); memset(&m_sequence_analysis, 0, sizeof(m_sequence_analysis)); m_ui->showComboBox->blockSignals(true); m_ui->showComboBox->setCurrentIndex(0); m_ui->showComboBox->blockSignals(false); m_sequence_analysis.all_packets = TRUE; m_sequence_analysis.any_addr = TRUE; QPushButton * save_bt = m_ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS)); // XXX Use recent settings instead if (parent) { resize(parent->width(), parent->height() * 4 / 5); } connect(m_ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int))); connect(m_ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int))); connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*))); connect(this, SIGNAL(goToPacket(int)), m_sequence_diagram, SLOT(setSelectedPacket(int))); disconnect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); fillDiagram(); }