本文整理汇总了C++中QCustomPlot::axisRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QCustomPlot::axisRect方法的具体用法?C++ QCustomPlot::axisRect怎么用?C++ QCustomPlot::axisRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCustomPlot
的用法示例。
在下文中一共展示了QCustomPlot::axisRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zoomAxes
void LteRlcGraphDialog::zoomAxes(bool in)
{
QCustomPlot *rp = ui->rlcPlot;
double h_factor = rp->axisRect()->rangeZoomFactor(Qt::Horizontal);
double v_factor = rp->axisRect()->rangeZoomFactor(Qt::Vertical);
if (!in) {
h_factor = pow(h_factor, -1);
v_factor = pow(v_factor, -1);
}
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;
}
}
rp->xAxis->scaleRange(h_factor, rp->xAxis->range().center());
rp->yAxis->scaleRange(v_factor, rp->yAxis->range().center());
rp->replot(QCustomPlot::rpQueued);
}
示例2: toggleVerticalDrag
void viewGVpropertieslayout::toggleVerticalDrag() {
// first get a pointer to the current plot!
QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget();
if (currPlot->axisRect()->rangeDrag() & Qt::Vertical)
currPlot->axisRect()->setRangeDrag(currPlot->axisRect()->rangeDrag() & ~Qt::Vertical);
else
currPlot->axisRect()->setRangeDrag(currPlot->axisRect()->rangeDrag() | Qt::Vertical);
}
示例3: contextMenuRequest
void viewGVpropertieslayout::contextMenuRequest(QPoint pos)
{
// first get a pointer to the current plot!
QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget();
QMenu *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose);
if (currPlot->legend->selectTest(pos, false) >= 0) // context menu on legend requested
{
/*menu->addAction("Move to top left", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignLeft));
menu->addAction("Move to top center", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignHCenter));
menu->addAction("Move to top right", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignRight));
menu->addAction("Move to bottom right", this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignRight));
menu->addAction("Move to bottom left", this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignLeft));*/
} else if (currPlot->xAxis->selectTest(pos, false) >= 0 || \
currPlot->xAxis2->selectTest(pos, false) >= 0)
{
// enable / disable zoom
if (currPlot->axisRect()->rangeZoom() & Qt::Horizontal)
menu->addAction("Disable zoom on axis", this, SLOT(toggleHorizontalZoom()));
else
menu->addAction("Enable zoom on axis", this, SLOT(toggleHorizontalZoom()));
// enable / diable drag
if (currPlot->axisRect()->rangeDrag() & Qt::Horizontal)
menu->addAction("Disable drag on axis", this, SLOT(toggleHorizontalDrag()));
else
menu->addAction("Enable drag on axis", this, SLOT(toggleHorizontalDrag()));
} else if (currPlot->yAxis->selectTest(pos, false) >= 0 || \
currPlot->yAxis2->selectTest(pos, false) >= 0)
{
// enable / disable zoom
if (currPlot->axisRect()->rangeZoom() & Qt::Vertical)
menu->addAction("Disable zoom on axis", this, SLOT(toggleVerticalZoom()));
else
menu->addAction("Enable zoom on axis", this, SLOT(toggleVerticalZoom()));
// enable / diable drag
if (currPlot->axisRect()->rangeDrag() & Qt::Vertical)
menu->addAction("Disable drag on axis", this, SLOT(toggleVerticalDrag()));
else
menu->addAction("Enable drag on axis", this, SLOT(toggleVerticalDrag()));
} else
{
if (currPlot->graphCount() > 0)
menu->addAction("Scale axes to fit", this, SLOT(rescaleAxes()));
if (currPlot->selectedGraphs().size() > 0)
menu->addAction("Remove selected graph", this, SLOT(removeSelectedGraph()));
if (currPlot->graphCount() > 0)
menu->addAction("Remove all graphs", this, SLOT(removeAllGraphs()));
}
menu->popup(currPlot->mapToGlobal(pos));
}
示例4: createWaveFormPic
void Record::createWaveFormPic(Ffmpeg_t *ffmpeg, QString recortPath) {
std::pair<std::vector<double>, std::vector<double> > dataWaveForm = ffmpeg->getSamplesForWaveformPlotting(recortPath + "/" + m_Name);
QCustomPlot Plotter;
Plotter.setBackground(QBrush(Qt::transparent) );
Plotter.xAxis->setVisible(false);
Plotter.yAxis->setVisible(false);
Plotter.axisRect()->setAutoMargins(QCP::msNone);
Plotter.axisRect()->setMargins(QMargins(0, 5, 0, 5));
QCPGraph *Waveform = Plotter.addGraph();
Waveform->setPen(QPen(Qt::green) );
if (!Waveform)
{
qDebug("addGraph failed\n");
}
QVector<double> Amplitudes(QVector<double>::fromStdVector(dataWaveForm.first) );
QVector<double> Time;
double CurrentTime = 0;
auto TimeSlotCount = Amplitudes.size();
for (int64_t i = 1; i < TimeSlotCount; i++)
{
Time.append(CurrentTime);
CurrentTime += 0.5;
}
Waveform->setData(Time, Amplitudes);
Plotter.xAxis->setRange(0, Time.back() );
Plotter.yAxis->setRange(SHRT_MIN, SHRT_MAX);
QByteArray ByteArray;
QBuffer Buffer(&ByteArray);
Buffer.open(QBuffer::WriteOnly);
uint32_t time = m_EndTime - m_StartTime;
for (int i = 1; i < 10000; i*=10) {
Plotter.toPixmap(time/(i), this->height()).save(&Buffer, "PNG", 0);
//Plotter.saveJpg(recortPath + "/plot" + QString::number(m_Id) + QString::number(i) + ".jpg", time/(i), this->height());
QPixmap Pixmap;
Pixmap.loadFromData(ByteArray, "PNG");
v_PixWaves.append(Pixmap);
ByteArray.clear();
Buffer.reset();
}
Buffer.close();
qDebug() << m_WavePic->margin();
// místo 2 podle toho jaký zoom
m_WavePic->setPixmap(v_PixWaves[2]);
}
示例5: 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);
}
示例6: zoomAxes
void TCPStreamDialog::zoomAxes(bool in)
{
QCustomPlot *sp = ui->streamPlot;
double h_factor = sp->axisRect()->rangeZoomFactor(Qt::Horizontal);
double v_factor = sp->axisRect()->rangeZoomFactor(Qt::Vertical);
if (!in) {
h_factor = pow(h_factor, -1);
v_factor = pow(v_factor, -1);
}
sp->xAxis->scaleRange(h_factor, sp->xAxis->range().center());
sp->yAxis->scaleRange(v_factor, sp->yAxis->range().center());
sp->replot();
}
示例7: mouseMoved
void SequenceDialog::mouseMoved(QMouseEvent *event)
{
QCustomPlot *sp = ui->sequencePlot;
Qt::CursorShape shape = Qt::ArrowCursor;
if (event) {
if (event->buttons().testFlag(Qt::LeftButton)) {
shape = Qt::ClosedHandCursor;
} else {
if (sp->axisRect()->rect().contains(event->pos())) {
shape = Qt::OpenHandCursor;
}
}
}
sp->setCursor(QCursor(shape));
packet_num_ = 0;
QString hint;
if (event) {
seq_analysis_item_t *sai = seq_diagram_->itemForPosY(event->pos().y());
if (sai) {
packet_num_ = sai->fd->num;
hint = QString("Packet %1: %2").arg(packet_num_).arg(sai->comment);
}
}
if (hint.isEmpty()) {
hint += tr("%Ln node(s)", "", seq_analysis_.num_nodes) + QString(", ")
+ tr("%Ln item(s)", "", num_items_);
}
hint.prepend("<small><i>");
hint.append("</i></small>");
ui->hintLabel->setText(hint);
}
示例8: zoomXAxis
void LteRlcGraphDialog::zoomXAxis(bool in)
{
QCustomPlot *rp = ui->rlcPlot;
double h_factor = rp->axisRect()->rangeZoomFactor(Qt::Horizontal);
if (!in) {
h_factor = pow(h_factor, -1);
}
rp->xAxis->scaleRange(h_factor, rp->xAxis->range().center());
rp->replot(QCustomPlot::rpQueued);
}
示例9: diagramClicked
void SequenceDialog::diagramClicked(QMouseEvent *event)
{
QCustomPlot *sp = ui->sequencePlot;
if (event->button() == Qt::RightButton) {
// XXX We should find some way to get sequenceDiagram to handle a
// contextMenuEvent instead.
ctx_menu_.exec(event->globalPos());
} else if (sp->axisRect()->rect().contains(event->pos())) {
sp->setCursor(QCursor(Qt::ClosedHandCursor));
}
on_actionGoToPacket_triggered();
}
示例10: graphClicked
void TCPStreamDialog::graphClicked(QMouseEvent *event)
{
QCustomPlot *sp = ui->streamPlot;
if (event->button() == Qt::RightButton) {
// XXX We should find some way to get streamPlot to handle a
// contextMenuEvent instead.
ctx_menu_.exec(event->globalPos());
} else if (mouse_drags_) {
if (sp->axisRect()->rect().contains(event->pos())) {
sp->setCursor(QCursor(Qt::ClosedHandCursor));
}
on_actionGoToPacket_triggered();
} else {
if (!rubber_band_) {
rubber_band_ = new QRubberBand(QRubberBand::Rectangle, sp);
}
rb_origin_ = event->pos();
rubber_band_->setGeometry(QRect(rb_origin_, QSize()));
rubber_band_->show();
}
}
示例11: getZoomRanges
QRectF LteRlcGraphDialog::getZoomRanges(QRect zoom_rect)
{
QRectF zoom_ranges = QRectF();
if (zoom_rect.width() < min_zoom_pixels_ && zoom_rect.height() < min_zoom_pixels_) {
return zoom_ranges;
}
QCustomPlot *rp = ui->rlcPlot;
QRect zr = zoom_rect.normalized();
QRect ar = rp->axisRect()->rect();
if (ar.intersects(zr)) {
QRect zsr = ar.intersected(zr);
zoom_ranges.setX(rp->xAxis->range().lower
+ rp->xAxis->range().size() * (zsr.left() - ar.left()) / ar.width());
zoom_ranges.setWidth(rp->xAxis->range().size() * zsr.width() / ar.width());
// QRects grow down
zoom_ranges.setY(rp->yAxis->range().lower
+ rp->yAxis->range().size() * (ar.bottom() - zsr.bottom()) / ar.height());
zoom_ranges.setHeight(rp->yAxis->range().size() * zsr.height() / ar.height());
}
return zoom_ranges;
}
示例12: createChart
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;
}
示例13: WiresharkDialog
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();
}
示例14: QDialog
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();
}
示例15: repaintplot
void chartcreate::repaintplot()
{
QCustomPlot * customPlot = ui->chart_preview;
// create empty bar chart objects:
QCPBars *regen = new QCPBars(customPlot->xAxis, customPlot->yAxis);
QCPBars *nuclear = new QCPBars(customPlot->xAxis, customPlot->yAxis);
QCPBars *fossil = new QCPBars(customPlot->xAxis, customPlot->yAxis);
customPlot->addPlottable(regen);
customPlot->addPlottable(nuclear);
customPlot->addPlottable(fossil);
// set names and colors:
QPen pen;
pen.setWidthF(1.2);
fossil->setName("Danone");
pen.setColor(QColor(255, 131, 0));
fossil->setPen(pen);
fossil->setBrush(QColor(255, 131, 0, 50));
nuclear->setName("AuBonLait");
pen.setColor(QColor(1, 92, 191));
nuclear->setPen(pen);
nuclear->setBrush(QColor(1, 92, 191, 50));
regen->setName("Yoplait");
pen.setColor(QColor(150, 222, 0));
regen->setPen(pen);
regen->setBrush(QColor(150, 222, 0, 70));
// stack bars ontop of each other:
nuclear->moveAbove(fossil);
regen->moveAbove(nuclear);
// prepare x axis with country labels:
QVector<double> ticks;
QVector<QString> labels;
ticks << 1 << 2 ;
labels << "Homme" << "Femme" ;
customPlot->xAxis->setAutoTicks(false);
customPlot->xAxis->setAutoTickLabels(false);
customPlot->xAxis->setTickVector(ticks);
customPlot->xAxis->setTickVectorLabels(labels);
customPlot->xAxis->setTickLabelRotation(60);
customPlot->xAxis->setSubTickCount(0);
customPlot->xAxis->setTickLength(0, 4);
customPlot->xAxis->grid()->setVisible(true);
customPlot->xAxis->setRange(0, 8);
// prepare y axis:
customPlot->yAxis->setRange(0, 12.1);
customPlot->yAxis->setPadding(5); // a bit more space to the left border
customPlot->yAxis->setLabel("Marque de Yaourt Connu");
customPlot->yAxis->grid()->setSubGridVisible(true);
QPen gridPen;
gridPen.setStyle(Qt::SolidLine);
gridPen.setColor(QColor(0, 0, 0, 25));
customPlot->yAxis->grid()->setPen(gridPen);
gridPen.setStyle(Qt::DotLine);
customPlot->yAxis->grid()->setSubGridPen(gridPen);
// Add data:
QVector<double> fossilData, nuclearData, regenData;
fossilData << 0.86*10.5 << 0.83*5.5;
nuclearData << 0.08*10.5 << 0.12*5.5;
regenData << 0.06*10.5 << 0.05*5.5;
fossil->setData(ticks, fossilData);
nuclear->setData(ticks, nuclearData);
regen->setData(ticks, regenData);
// setup legend:
customPlot->legend->setVisible(true);
customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter);
customPlot->legend->setBrush(QColor(255, 255, 255, 200));
QPen legendPen;
legendPen.setColor(QColor(130, 130, 130, 200));
customPlot->legend->setBorderPen(legendPen);
QFont legendFont = font();
legendFont.setPointSize(10);
customPlot->legend->setFont(legendFont);
customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
}