diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 4b7da04..0db4c72 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -20,10 +20,10 @@ base = (qrand() % 100000) * 1000; - QTimer * timer = new QTimer(this); - connect(timer, &QTimer::timeout, - this, &PhaseDevice::mockPhaseData); - timer->start(1000); +// QTimer * timer = new QTimer(this); +// connect(timer, &QTimer::timeout, +// this, &PhaseDevice::mockPhaseData); +// timer->start(1000); } PhaseDevice::~PhaseDevice() diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 4b7da04..0db4c72 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -20,10 +20,10 @@ base = (qrand() % 100000) * 1000; - QTimer * timer = new QTimer(this); - connect(timer, &QTimer::timeout, - this, &PhaseDevice::mockPhaseData); - timer->start(1000); +// QTimer * timer = new QTimer(this); +// connect(timer, &QTimer::timeout, +// this, &PhaseDevice::mockPhaseData); +// timer->start(1000); } PhaseDevice::~PhaseDevice() diff --git a/PhaseMeasure.pro b/PhaseMeasure.pro index 8f6a23d..d247f1b 100644 --- a/PhaseMeasure.pro +++ b/PhaseMeasure.pro @@ -39,6 +39,7 @@ DISTFILES += conf/config.ini DISTFILES += qss/pmdark.css +DISTFILES += qss/dlgdark.css RESOURCES += images.qrc RC_ICONS = PhaseMeasure.ico diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 4b7da04..0db4c72 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -20,10 +20,10 @@ base = (qrand() % 100000) * 1000; - QTimer * timer = new QTimer(this); - connect(timer, &QTimer::timeout, - this, &PhaseDevice::mockPhaseData); - timer->start(1000); +// QTimer * timer = new QTimer(this); +// connect(timer, &QTimer::timeout, +// this, &PhaseDevice::mockPhaseData); +// timer->start(1000); } PhaseDevice::~PhaseDevice() diff --git a/PhaseMeasure.pro b/PhaseMeasure.pro index 8f6a23d..d247f1b 100644 --- a/PhaseMeasure.pro +++ b/PhaseMeasure.pro @@ -39,6 +39,7 @@ DISTFILES += conf/config.ini DISTFILES += qss/pmdark.css +DISTFILES += qss/dlgdark.css RESOURCES += images.qrc RC_ICONS = PhaseMeasure.ico diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index b8e48ef..976f1d5 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -96,7 +96,6 @@ foreach (QToolButton *btn, tbtns) { btn->setIconSize(icoSize); btn->setMinimumWidth(icoWidth); - btn->setCheckable(true); connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); } ui->endButt->setVisible(running); @@ -183,7 +182,7 @@ bool ok = folder->mkdir(SettingConfig::getInstance().BASE_LOG_PATH + fileName); if(ok) { currentFileName = fileName; - QMessageBox::warning(this, tr("开始"), tr("开始成功")); + QMessageBox::information(this, tr("开始"), tr("开始成功")); } } } @@ -231,18 +230,9 @@ void PhaseWindow::buttonClick() { - QToolButton *b = (QToolButton *)sender(); + QToolButton * b = (QToolButton *)sender(); QString name = b->text(); - QList tbtns = ui->widgetTop->findChildren(); - foreach (QToolButton *btn, tbtns) { - if (btn == b) { - btn->setChecked(true); - } else { - btn->setChecked(false); - } - } - // 如果是开始或者结束测量按钮被点击则切换显示按钮 if (name.contains("开始") || name.contains("停止") || name.contains("测量")) { swiftConntrollerButt(); @@ -274,7 +264,7 @@ void PhaseWindow::on_settingButt_clicked() { - SetConfig *new_win = new SetConfig(); - new_win->setWindowTitle("配置"); - new_win->show(); + SetConfig * settingDlg = new SetConfig(); + settingDlg->setModal(true); + settingDlg->show(); } diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 4b7da04..0db4c72 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -20,10 +20,10 @@ base = (qrand() % 100000) * 1000; - QTimer * timer = new QTimer(this); - connect(timer, &QTimer::timeout, - this, &PhaseDevice::mockPhaseData); - timer->start(1000); +// QTimer * timer = new QTimer(this); +// connect(timer, &QTimer::timeout, +// this, &PhaseDevice::mockPhaseData); +// timer->start(1000); } PhaseDevice::~PhaseDevice() diff --git a/PhaseMeasure.pro b/PhaseMeasure.pro index 8f6a23d..d247f1b 100644 --- a/PhaseMeasure.pro +++ b/PhaseMeasure.pro @@ -39,6 +39,7 @@ DISTFILES += conf/config.ini DISTFILES += qss/pmdark.css +DISTFILES += qss/dlgdark.css RESOURCES += images.qrc RC_ICONS = PhaseMeasure.ico diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index b8e48ef..976f1d5 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -96,7 +96,6 @@ foreach (QToolButton *btn, tbtns) { btn->setIconSize(icoSize); btn->setMinimumWidth(icoWidth); - btn->setCheckable(true); connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); } ui->endButt->setVisible(running); @@ -183,7 +182,7 @@ bool ok = folder->mkdir(SettingConfig::getInstance().BASE_LOG_PATH + fileName); if(ok) { currentFileName = fileName; - QMessageBox::warning(this, tr("开始"), tr("开始成功")); + QMessageBox::information(this, tr("开始"), tr("开始成功")); } } } @@ -231,18 +230,9 @@ void PhaseWindow::buttonClick() { - QToolButton *b = (QToolButton *)sender(); + QToolButton * b = (QToolButton *)sender(); QString name = b->text(); - QList tbtns = ui->widgetTop->findChildren(); - foreach (QToolButton *btn, tbtns) { - if (btn == b) { - btn->setChecked(true); - } else { - btn->setChecked(false); - } - } - // 如果是开始或者结束测量按钮被点击则切换显示按钮 if (name.contains("开始") || name.contains("停止") || name.contains("测量")) { swiftConntrollerButt(); @@ -274,7 +264,7 @@ void PhaseWindow::on_settingButt_clicked() { - SetConfig *new_win = new SetConfig(); - new_win->setWindowTitle("配置"); - new_win->show(); + SetConfig * settingDlg = new SetConfig(); + settingDlg->setModal(true); + settingDlg->show(); } diff --git a/SetConfig.cpp b/SetConfig.cpp index 964bc9e..d9b6273 100644 --- a/SetConfig.cpp +++ b/SetConfig.cpp @@ -1,16 +1,42 @@ #include "SetConfig.h" #include "ui_SetConfig.h" -#include "QDebug" + +#include +#include +#include +#include + SetConfig::SetConfig(QWidget *parent) : QDialog(parent), ui(new Ui::SetConfig) { ui->setupUi(this); + + // 加载样式表 + QFile file(QApplication::applicationDirPath() + "/qss/dlgdark.css"); + if (file.open(QFile::ReadOnly)) { + QString qss = QLatin1String(file.readAll()); + this->setStyleSheet(qss); + file.close(); + } + init(); } void SetConfig::init() { - ui->IPInput->setText(SettingConfig::getInstance().DEVICE_HOST); + setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + setWindowFlags(Qt::Window | Qt::FramelessWindowHint + | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint + | Qt::WindowMaximizeButtonHint); + + this->setProperty("dialog", true); + + // 修改名称 + ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定"); + ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消"); + + ui->ipInput->setText(SettingConfig::getInstance().DEVICE_HOST); ui->devInput->setText(QString::number(SettingConfig::getInstance().DEVICE_PORT)); ui->listenInput->setText(QString::number(SettingConfig::getInstance().LISTEN_PORT)); ui->logInput->setText(SettingConfig::getInstance().BASE_LOG_PATH); @@ -22,7 +48,7 @@ void SetConfig::on_buttonBox_accepted() { - SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->IPInput->text()); + SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->ipInput->text()); SettingConfig::getInstance().setConProperty("net", "devicePort", ui->devInput->text()); SettingConfig::getInstance().setConProperty("net", "listenPort", ui->listenInput->text()); SettingConfig::getInstance().setConProperty("log", "basePath", ui->logInput->text()); diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 4b7da04..0db4c72 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -20,10 +20,10 @@ base = (qrand() % 100000) * 1000; - QTimer * timer = new QTimer(this); - connect(timer, &QTimer::timeout, - this, &PhaseDevice::mockPhaseData); - timer->start(1000); +// QTimer * timer = new QTimer(this); +// connect(timer, &QTimer::timeout, +// this, &PhaseDevice::mockPhaseData); +// timer->start(1000); } PhaseDevice::~PhaseDevice() diff --git a/PhaseMeasure.pro b/PhaseMeasure.pro index 8f6a23d..d247f1b 100644 --- a/PhaseMeasure.pro +++ b/PhaseMeasure.pro @@ -39,6 +39,7 @@ DISTFILES += conf/config.ini DISTFILES += qss/pmdark.css +DISTFILES += qss/dlgdark.css RESOURCES += images.qrc RC_ICONS = PhaseMeasure.ico diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index b8e48ef..976f1d5 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -96,7 +96,6 @@ foreach (QToolButton *btn, tbtns) { btn->setIconSize(icoSize); btn->setMinimumWidth(icoWidth); - btn->setCheckable(true); connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); } ui->endButt->setVisible(running); @@ -183,7 +182,7 @@ bool ok = folder->mkdir(SettingConfig::getInstance().BASE_LOG_PATH + fileName); if(ok) { currentFileName = fileName; - QMessageBox::warning(this, tr("开始"), tr("开始成功")); + QMessageBox::information(this, tr("开始"), tr("开始成功")); } } } @@ -231,18 +230,9 @@ void PhaseWindow::buttonClick() { - QToolButton *b = (QToolButton *)sender(); + QToolButton * b = (QToolButton *)sender(); QString name = b->text(); - QList tbtns = ui->widgetTop->findChildren(); - foreach (QToolButton *btn, tbtns) { - if (btn == b) { - btn->setChecked(true); - } else { - btn->setChecked(false); - } - } - // 如果是开始或者结束测量按钮被点击则切换显示按钮 if (name.contains("开始") || name.contains("停止") || name.contains("测量")) { swiftConntrollerButt(); @@ -274,7 +264,7 @@ void PhaseWindow::on_settingButt_clicked() { - SetConfig *new_win = new SetConfig(); - new_win->setWindowTitle("配置"); - new_win->show(); + SetConfig * settingDlg = new SetConfig(); + settingDlg->setModal(true); + settingDlg->show(); } diff --git a/SetConfig.cpp b/SetConfig.cpp index 964bc9e..d9b6273 100644 --- a/SetConfig.cpp +++ b/SetConfig.cpp @@ -1,16 +1,42 @@ #include "SetConfig.h" #include "ui_SetConfig.h" -#include "QDebug" + +#include +#include +#include +#include + SetConfig::SetConfig(QWidget *parent) : QDialog(parent), ui(new Ui::SetConfig) { ui->setupUi(this); + + // 加载样式表 + QFile file(QApplication::applicationDirPath() + "/qss/dlgdark.css"); + if (file.open(QFile::ReadOnly)) { + QString qss = QLatin1String(file.readAll()); + this->setStyleSheet(qss); + file.close(); + } + init(); } void SetConfig::init() { - ui->IPInput->setText(SettingConfig::getInstance().DEVICE_HOST); + setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + setWindowFlags(Qt::Window | Qt::FramelessWindowHint + | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint + | Qt::WindowMaximizeButtonHint); + + this->setProperty("dialog", true); + + // 修改名称 + ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定"); + ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消"); + + ui->ipInput->setText(SettingConfig::getInstance().DEVICE_HOST); ui->devInput->setText(QString::number(SettingConfig::getInstance().DEVICE_PORT)); ui->listenInput->setText(QString::number(SettingConfig::getInstance().LISTEN_PORT)); ui->logInput->setText(SettingConfig::getInstance().BASE_LOG_PATH); @@ -22,7 +48,7 @@ void SetConfig::on_buttonBox_accepted() { - SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->IPInput->text()); + SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->ipInput->text()); SettingConfig::getInstance().setConProperty("net", "devicePort", ui->devInput->text()); SettingConfig::getInstance().setConProperty("net", "listenPort", ui->listenInput->text()); SettingConfig::getInstance().setConProperty("log", "basePath", ui->logInput->text()); diff --git a/SetConfig.ui b/SetConfig.ui index 5697653..c17a73e 100644 --- a/SetConfig.ui +++ b/SetConfig.ui @@ -17,7 +17,7 @@ 30 - 241 + 250 341 31 @@ -27,6 +27,9 @@ 10 + + background-color: rgb(47, 53, 66); + Qt::Horizontal @@ -37,11 +40,11 @@ false - + 20 - 30 + 50 101 181 @@ -59,7 +62,7 @@ IP: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -75,7 +78,7 @@ 设备端口: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -91,7 +94,7 @@ 监听端口: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -107,24 +110,24 @@ 日志地址: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 120 - 30 + 50 261 181 - + 0 @@ -181,10 +184,48 @@ 11 + + false + + + + + 20 + 5 + 80 + 30 + + + + + 微软雅黑 + 12 + + + + 系统设置 + + + + + + 1 + 45 + 398 + 3 + + + + QFrame::Plain + + + Qt::Horizontal + + diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 4b7da04..0db4c72 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -20,10 +20,10 @@ base = (qrand() % 100000) * 1000; - QTimer * timer = new QTimer(this); - connect(timer, &QTimer::timeout, - this, &PhaseDevice::mockPhaseData); - timer->start(1000); +// QTimer * timer = new QTimer(this); +// connect(timer, &QTimer::timeout, +// this, &PhaseDevice::mockPhaseData); +// timer->start(1000); } PhaseDevice::~PhaseDevice() diff --git a/PhaseMeasure.pro b/PhaseMeasure.pro index 8f6a23d..d247f1b 100644 --- a/PhaseMeasure.pro +++ b/PhaseMeasure.pro @@ -39,6 +39,7 @@ DISTFILES += conf/config.ini DISTFILES += qss/pmdark.css +DISTFILES += qss/dlgdark.css RESOURCES += images.qrc RC_ICONS = PhaseMeasure.ico diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index b8e48ef..976f1d5 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -96,7 +96,6 @@ foreach (QToolButton *btn, tbtns) { btn->setIconSize(icoSize); btn->setMinimumWidth(icoWidth); - btn->setCheckable(true); connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); } ui->endButt->setVisible(running); @@ -183,7 +182,7 @@ bool ok = folder->mkdir(SettingConfig::getInstance().BASE_LOG_PATH + fileName); if(ok) { currentFileName = fileName; - QMessageBox::warning(this, tr("开始"), tr("开始成功")); + QMessageBox::information(this, tr("开始"), tr("开始成功")); } } } @@ -231,18 +230,9 @@ void PhaseWindow::buttonClick() { - QToolButton *b = (QToolButton *)sender(); + QToolButton * b = (QToolButton *)sender(); QString name = b->text(); - QList tbtns = ui->widgetTop->findChildren(); - foreach (QToolButton *btn, tbtns) { - if (btn == b) { - btn->setChecked(true); - } else { - btn->setChecked(false); - } - } - // 如果是开始或者结束测量按钮被点击则切换显示按钮 if (name.contains("开始") || name.contains("停止") || name.contains("测量")) { swiftConntrollerButt(); @@ -274,7 +264,7 @@ void PhaseWindow::on_settingButt_clicked() { - SetConfig *new_win = new SetConfig(); - new_win->setWindowTitle("配置"); - new_win->show(); + SetConfig * settingDlg = new SetConfig(); + settingDlg->setModal(true); + settingDlg->show(); } diff --git a/SetConfig.cpp b/SetConfig.cpp index 964bc9e..d9b6273 100644 --- a/SetConfig.cpp +++ b/SetConfig.cpp @@ -1,16 +1,42 @@ #include "SetConfig.h" #include "ui_SetConfig.h" -#include "QDebug" + +#include +#include +#include +#include + SetConfig::SetConfig(QWidget *parent) : QDialog(parent), ui(new Ui::SetConfig) { ui->setupUi(this); + + // 加载样式表 + QFile file(QApplication::applicationDirPath() + "/qss/dlgdark.css"); + if (file.open(QFile::ReadOnly)) { + QString qss = QLatin1String(file.readAll()); + this->setStyleSheet(qss); + file.close(); + } + init(); } void SetConfig::init() { - ui->IPInput->setText(SettingConfig::getInstance().DEVICE_HOST); + setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + setWindowFlags(Qt::Window | Qt::FramelessWindowHint + | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint + | Qt::WindowMaximizeButtonHint); + + this->setProperty("dialog", true); + + // 修改名称 + ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定"); + ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消"); + + ui->ipInput->setText(SettingConfig::getInstance().DEVICE_HOST); ui->devInput->setText(QString::number(SettingConfig::getInstance().DEVICE_PORT)); ui->listenInput->setText(QString::number(SettingConfig::getInstance().LISTEN_PORT)); ui->logInput->setText(SettingConfig::getInstance().BASE_LOG_PATH); @@ -22,7 +48,7 @@ void SetConfig::on_buttonBox_accepted() { - SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->IPInput->text()); + SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->ipInput->text()); SettingConfig::getInstance().setConProperty("net", "devicePort", ui->devInput->text()); SettingConfig::getInstance().setConProperty("net", "listenPort", ui->listenInput->text()); SettingConfig::getInstance().setConProperty("log", "basePath", ui->logInput->text()); diff --git a/SetConfig.ui b/SetConfig.ui index 5697653..c17a73e 100644 --- a/SetConfig.ui +++ b/SetConfig.ui @@ -17,7 +17,7 @@ 30 - 241 + 250 341 31 @@ -27,6 +27,9 @@ 10 + + background-color: rgb(47, 53, 66); + Qt::Horizontal @@ -37,11 +40,11 @@ false - + 20 - 30 + 50 101 181 @@ -59,7 +62,7 @@ IP: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -75,7 +78,7 @@ 设备端口: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -91,7 +94,7 @@ 监听端口: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -107,24 +110,24 @@ 日志地址: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 120 - 30 + 50 261 181 - + 0 @@ -181,10 +184,48 @@ 11 + + false + + + + + 20 + 5 + 80 + 30 + + + + + 微软雅黑 + 12 + + + + 系统设置 + + + + + + 1 + 45 + 398 + 3 + + + + QFrame::Plain + + + Qt::Horizontal + + diff --git a/qss/dlgdark.css b/qss/dlgdark.css new file mode 100644 index 0000000..c28364f --- /dev/null +++ b/qss/dlgdark.css @@ -0,0 +1,16 @@ +QDialog[dialog="true"] { + background: #666666; + border: 1px solid #2f3542; + border-radius: 0px; +} + +QWidget#inputWgt QLineEdit { + background: #2f3542; + color: #e8eaee; + border:1px solid #57606f; + border-radius: 4px; +} + +QDialogButtonBox#buttonBox { + background: #2f3542; +} \ No newline at end of file diff --git a/ChannelCharts.cpp b/ChannelCharts.cpp index 954522e..6d713e3 100644 --- a/ChannelCharts.cpp +++ b/ChannelCharts.cpp @@ -2,6 +2,7 @@ #include "ui_ChannelCharts.h" #include +#include "IconHelper.h" extern QVector> phaseVector; extern QVector> channelAllan; @@ -12,6 +13,15 @@ { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + this->setWindowFlags(Qt::FramelessWindowHint); + QRect screenRect = QApplication::desktop()->availableGeometry(); + qint16 screenWidth = screenRect.width(); + qint16 screenHeight = screenRect.height(); + resize(screenWidth, screenHeight); + + IconHelper::Instance()->setIcon(ui->closeButt, QChar(0xf00d)); + ui->closeButt->setStyleSheet("border-style:none; border-radius:0px; padding:5px; color:#DCDCDC;"); } ChannelCharts::~ChannelCharts() @@ -19,12 +29,17 @@ delete ui; } +void ChannelCharts::setTitleText(QString titleText) +{ + ui->label->setText(titleText); +} + void ChannelCharts::initDataChart(int index) { QCPGraph * graph = ui->dataPlot->addGraph(); graph->setName("时差(ns)"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) - graph->setPen(QPen(QColor("#ff4757"))); + graph->setPen(QPen(QColor(0, 168, 140))); // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). QSharedPointer timeTicker(new QCPAxisTickerDateTime); @@ -33,71 +48,66 @@ ui->dataPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->dataPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 + QLinearGradient gradient(0, 0, 0, 400); + gradient.setColorAt(0, QColor(90, 90, 90)); + gradient.setColorAt(0.38, QColor(105, 105, 105)); + gradient.setColorAt(1, QColor(70, 70, 70)); + ui->dataPlot->setBackground(QBrush(gradient)); + + ui->dataPlot->xAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->xAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->xAxis->setPadding(5); + ui->dataPlot->xAxis->grid()->setVisible(true); + ui->dataPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); + ui->dataPlot->xAxis->setTickLabelColor(Qt::white); + ui->dataPlot->xAxis->setLabelColor(Qt::white); ui->dataPlot->xAxis->setLabel("时间"); + + ui->dataPlot->yAxis->setPadding(5); // a bit more space to the left border ui->dataPlot->yAxis->setLabel("时差测量值"); -/* - // 游标 - QCPItemTracer * tracer = new QCPItemTracer(ui->dataPlot); - tracer->setInterpolating(false); // 禁用插值,游标自动吸附到最近的点 - tracer->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 颜色、宽度、线型 // 标签色(warning) #FAA732 - tracer->setStyle(QCPItemTracer::tsCircle); // 样式:十字星、圆圈、方框等 - tracer->setSize(10.0); + ui->dataPlot->yAxis->setBasePen(QPen(Qt::white)); + ui->dataPlot->yAxis->setTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->setSubTickPen(QPen(Qt::white)); + ui->dataPlot->yAxis->grid()->setSubGridVisible(true); + ui->dataPlot->yAxis->setTickLabelColor(Qt::white); + ui->dataPlot->yAxis->setLabelColor(Qt::white); + ui->dataPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); + ui->dataPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - // 游标数据标签 - QCPItemText * tracerLabel = new QCPItemText(ui->dataPlot); - tracerLabel->setLayer("overlay"); - tracerLabel->setPositionAlignment(Qt::AlignLeft | Qt::AlignTop); - tracerLabel->setTextAlignment(Qt::AlignLeft); - tracerLabel->setPadding(QMargins(5, 5, 5, 5)); // 边界宽度 - tracerLabel->position->setParentAnchor(tracer->position); // 锚固在tracer位置处,实现自动跟随 - - // 游标垂直线 - QCPItemStraightLine * tracerLineV = new QCPItemStraightLine(ui->dataPlot); - tracerLineV->setLayer("overlay"); - tracerLineV->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineV->setClipToAxisRect(true); - tracerLineV->point1->setCoords(0, 0); - tracerLineV->point2->setCoords(0, 0); - - // 游标水平线 - QCPItemStraightLine * tracerLineH = new QCPItemStraightLine(ui->dataPlot); - tracerLineH->setLayer("overlay"); - tracerLineH->setPen(QPen(QColor("#FAA732"), 1, Qt::DashLine)); // 标签色(warning) #FAA732 - tracerLineH->setClipToAxisRect(true); - tracerLineH->point1->setCoords(0, 0); - tracerLineH->point2->setCoords(0, 0); -*/ - double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; - double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; - double minValue = phaseVector[index].first().at(1).toDouble(); - double maxValue = phaseVector[index].first().at(1).toDouble(); - QVector vecPoints; - - for (int i = 0; i < phaseVector[index].size(); i++) + if (phaseVector[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minTm = phaseVector[index].first().at(0).toLongLong() / 1000; + double maxTm = phaseVector[index].last().at(0).toLongLong() / 1000; + double minValue = phaseVector[index].first().at(1).toDouble(); + double maxValue = phaseVector[index].first().at(1).toDouble(); + QVector vecPoints; - QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 - onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); - onePoint.value = phaseVector[index].at(i).at(1).toDouble(); - - vecPoints.append(onePoint); - - if (phaseVector[index].at(i).at(1).toDouble() < minValue) + for (int i = 0; i < phaseVector[index].size(); i++) { - minValue = phaseVector[index][i].at(1).toDouble(); - } + // 新的数据点 + QCPGraphData onePoint; - if (phaseVector[index].at(i).at(1).toDouble() > maxValue) - { - maxValue = phaseVector[index][i].at(1).toDouble(); + QDateTime dtime = QDateTime::fromSecsSinceEpoch(phaseVector[index].at(i).at(0).toLongLong() / 1000); // 日期时间 + onePoint.key = QCPAxisTickerDateTime::dateTimeToKey(dtime); + onePoint.value = phaseVector[index].at(i).at(1).toDouble(); + + vecPoints.append(onePoint); + + if (phaseVector[index].at(i).at(1).toDouble() < minValue) + { + minValue = phaseVector[index][i].at(1).toDouble(); + } + + if (phaseVector[index].at(i).at(1).toDouble() > maxValue) + { + maxValue = phaseVector[index][i].at(1).toDouble(); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->dataPlot->xAxis->setRange(minTm, maxTm); + ui->dataPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->dataPlot->xAxis->setRange(minTm, maxTm); - ui->dataPlot->yAxis->setRange(minValue, maxValue); ui->dataPlot->legend->setVisible(false); // ui->dataPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); @@ -105,84 +115,8 @@ void ChannelCharts::initAllenChart(int index) { - /* - QLinearGradient gradient(0, 0, 0, 400); - gradient.setColorAt(0, QColor(90, 90, 90)); - gradient.setColorAt(0.38, QColor(105, 105, 105)); - gradient.setColorAt(1, QColor(70, 70, 70)); - ui->allenPlot->setBackground(QBrush(gradient)); - - // create empty bar chart objects: - QCPBars * allen = new QCPBars(ui->allenPlot->xAxis, ui->allenPlot->yAxis); - allen->setAntialiased(false); // gives more crisp, pixel aligned bar borders - - allen->setStackingGap(1); - // set names and colors: - allen->setName("allen"); - allen->setPen(QPen(QColor(0, 168, 140).lighter(130))); - allen->setBrush(QColor(0, 168, 140)); - // stack bars on top of each other: - - // prepare x axis with country labels: - QVector ticks; - QVector labels; - ticks << 1 << 2 << 3 << 4 << 5; - labels << "1" << "10" << "100" << "1000" << "10000"; - QSharedPointer textTicker(new QCPAxisTickerText); - textTicker->addTicks(ticks, labels); - ui->allenPlot->xAxis->setTicker(textTicker); - ui->allenPlot->xAxis->setSubTicks(false); - ui->allenPlot->xAxis->setTickLength(0, 4); - ui->allenPlot->xAxis->setRange(0, 6); - ui->allenPlot->xAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->xAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->xAxis->grid()->setVisible(true); - ui->allenPlot->xAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - ui->allenPlot->xAxis->setTickLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabelColor(Qt::white); - ui->allenPlot->xAxis->setLabel("平均时间(秒)"); - - // prepare y axis: - ui->allenPlot->yAxis->setRange(-1e-15, channelAllan[index].isEmpty() ? 0.1 : channelAllan[index][0]); - ui->allenPlot->yAxis->setPadding(5); // a bit more space to the left border - ui->allenPlot->yAxis->setLabel("阿伦方差"); - ui->allenPlot->yAxis->setBasePen(QPen(Qt::white)); - ui->allenPlot->yAxis->setTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->setSubTickPen(QPen(Qt::white)); - ui->allenPlot->yAxis->grid()->setSubGridVisible(true); - ui->allenPlot->yAxis->setTickLabelColor(Qt::white); - ui->allenPlot->yAxis->setLabelColor(Qt::white); - ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); - ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // Add data: - QVector allenData; - if (channelAllan[index].isEmpty() == true) { - allenData << 0.0 << 0.0 << 0.0 << 0.0 << 0.0; - } else - { - allenData << channelAllan[index][0] - << channelAllan[index][1] - << channelAllan[index][2] - << channelAllan[index][3] - << channelAllan[index][4]; - } - - allen->setData(ticks, allenData); - - // setup legend: - ui->allenPlot->legend->setVisible(false); -// ui->allenPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter); -// ui->allenPlot->legend->setBrush(QColor(255, 255, 255, 100)); -// ui->allenPlot->legend->setBorderPen(Qt::NoPen); -// QFont legendFont = font(); -// legendFont.setPointSize(10); -// ui->allenPlot->legend->setFont(legendFont); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); - */ - QCPGraph * graph = ui->allenPlot->addGraph(); - graph->setName("时差(ns)"); + graph->setName("阿伦方差"); graph->setAdaptiveSampling(true); // 默认启用自适应采样(绘图) QPen pen; pen.setColor(QColor(0, 168, 140)); @@ -215,44 +149,48 @@ ui->allenPlot->yAxis->grid()->setPen(QPen(QColor(130, 130, 130), 0, Qt::SolidLine)); ui->allenPlot->yAxis->grid()->setSubGridPen(QPen(QColor(130, 130, 130), 0, Qt::DotLine)); - - // 时间坐标轴 seconds since Epoch (January 1, 1970, 00:00 UTC). + // 对数坐标轴 横轴也缩放到对数 QSharedPointer logTicker(new QCPAxisTickerLog); ui->allenPlot->xAxis->setTicker(logTicker); ui->allenPlot->yAxis->setNumberFormat("gbc"); // Y 轴:g灵活的格式,b漂亮的指数形式,c乘号改成× ui->allenPlot->yAxis->setNumberPrecision(4); // Y 轴:精度,有效数字的位数 ui->allenPlot->xAxis->setScaleType(QCPAxis::stLogarithmic); - channelAllan[index] = {2.48e-13, 1.11e-13, 2.6e-14, 5.26e-15, 1.28e-15}; - - double minValue = channelAllan[index].first(); - double maxValue = channelAllan[index].first(); - QVector vecPoints; - - for (int i = 0; i < channelAllan[index].size(); i++) + if (channelAllan[index].isEmpty() == false) { - // 新的数据点 - QCPGraphData onePoint; + double minValue = channelAllan[index].first(); + double maxValue = channelAllan[index].first(); + QVector vecPoints; - onePoint.key = pow(10, i); - onePoint.value = channelAllan[index].at(i); - vecPoints.append(onePoint); - - if (channelAllan[index].at(i) < minValue) + for (int i = 0; i < channelAllan[index].size(); i++) { - minValue = channelAllan[index].at(i); - } + // 新的数据点 + QCPGraphData onePoint; - if (channelAllan[index].at(i) > maxValue) - { - maxValue = channelAllan[index].at(i); + onePoint.key = pow(10, i); + onePoint.value = channelAllan[index].at(i); + vecPoints.append(onePoint); + + if (channelAllan[index].at(i) < minValue) + { + minValue = channelAllan[index].at(i); + } + + if (channelAllan[index].at(i) > maxValue) + { + maxValue = channelAllan[index].at(i); + } } + graph->data()->clear(); + graph->data()->set(vecPoints, true); + ui->allenPlot->xAxis->setRange(1, 11000); + ui->allenPlot->yAxis->setRange(minValue, maxValue); } - graph->data()->clear(); - graph->data()->set(vecPoints, true); - ui->allenPlot->xAxis->setRange(1, 11000); - ui->allenPlot->yAxis->setRange(minValue, maxValue); - ui->allenPlot->legend->setVisible(false); - ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +// ui->allenPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); +} + +void ChannelCharts::on_closeButt_clicked() +{ + this->close(); } diff --git a/ChannelCharts.h b/ChannelCharts.h index b5a0a52..8ce1128 100644 --- a/ChannelCharts.h +++ b/ChannelCharts.h @@ -15,9 +15,13 @@ explicit ChannelCharts(QWidget *parent = nullptr); ~ChannelCharts(); + void setTitleText(QString titleText); void initAllenChart(int index); void initDataChart(int index); +private slots: + void on_closeButt_clicked(); + private: Ui::ChannelCharts *ui; diff --git a/ChannelCharts.ui b/ChannelCharts.ui index c385170..029ab73 100644 --- a/ChannelCharts.ui +++ b/ChannelCharts.ui @@ -13,7 +13,49 @@ Form - + + + + + 0 + + + QLayout::SetDefaultConstraint + + + + + + 16777215 + 30 + + + + + 微软雅黑 + 12 + + + + + + + + + + + + 30 + 30 + + + + × + + + + + diff --git a/ChannelItem.cpp b/ChannelItem.cpp index f94ee11..3370847 100644 --- a/ChannelItem.cpp +++ b/ChannelItem.cpp @@ -8,10 +8,11 @@ ui(new Ui::ChannelItem) { ui->setupUi(this); - ui->delay->setStyleSheet("height: 30px; border:1px solid; border-radius:4px;"); QFont font("微软雅黑"); font.setPixelSize(16); ui->delay->setFont(font); + + this->setProperty("form", "channel"); } ChannelItem::~ChannelItem() @@ -77,8 +78,8 @@ { ChannelCharts * chartFrame = new ChannelCharts(); chartFrame->setWindowModality(Qt::ApplicationModal); - chartFrame->setWindowTitle(QString("通道 - %1 数据曲线").arg(index + 1)); chartFrame->initAllenChart(index); chartFrame->initDataChart(index); + chartFrame->setTitleText((QString("通道 - %1 数据曲线").arg(index + 1))); chartFrame->show(); } diff --git a/ChannelItem.ui b/ChannelItem.ui index 13e7b17..3547b99 100644 --- a/ChannelItem.ui +++ b/ChannelItem.ui @@ -428,9 +428,6 @@ false - - background:none; - diff --git a/PhaseDevice.cpp b/PhaseDevice.cpp index 4b7da04..0db4c72 100644 --- a/PhaseDevice.cpp +++ b/PhaseDevice.cpp @@ -20,10 +20,10 @@ base = (qrand() % 100000) * 1000; - QTimer * timer = new QTimer(this); - connect(timer, &QTimer::timeout, - this, &PhaseDevice::mockPhaseData); - timer->start(1000); +// QTimer * timer = new QTimer(this); +// connect(timer, &QTimer::timeout, +// this, &PhaseDevice::mockPhaseData); +// timer->start(1000); } PhaseDevice::~PhaseDevice() diff --git a/PhaseMeasure.pro b/PhaseMeasure.pro index 8f6a23d..d247f1b 100644 --- a/PhaseMeasure.pro +++ b/PhaseMeasure.pro @@ -39,6 +39,7 @@ DISTFILES += conf/config.ini DISTFILES += qss/pmdark.css +DISTFILES += qss/dlgdark.css RESOURCES += images.qrc RC_ICONS = PhaseMeasure.ico diff --git a/PhaseWindow.cpp b/PhaseWindow.cpp index b8e48ef..976f1d5 100644 --- a/PhaseWindow.cpp +++ b/PhaseWindow.cpp @@ -96,7 +96,6 @@ foreach (QToolButton *btn, tbtns) { btn->setIconSize(icoSize); btn->setMinimumWidth(icoWidth); - btn->setCheckable(true); connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); } ui->endButt->setVisible(running); @@ -183,7 +182,7 @@ bool ok = folder->mkdir(SettingConfig::getInstance().BASE_LOG_PATH + fileName); if(ok) { currentFileName = fileName; - QMessageBox::warning(this, tr("开始"), tr("开始成功")); + QMessageBox::information(this, tr("开始"), tr("开始成功")); } } } @@ -231,18 +230,9 @@ void PhaseWindow::buttonClick() { - QToolButton *b = (QToolButton *)sender(); + QToolButton * b = (QToolButton *)sender(); QString name = b->text(); - QList tbtns = ui->widgetTop->findChildren(); - foreach (QToolButton *btn, tbtns) { - if (btn == b) { - btn->setChecked(true); - } else { - btn->setChecked(false); - } - } - // 如果是开始或者结束测量按钮被点击则切换显示按钮 if (name.contains("开始") || name.contains("停止") || name.contains("测量")) { swiftConntrollerButt(); @@ -274,7 +264,7 @@ void PhaseWindow::on_settingButt_clicked() { - SetConfig *new_win = new SetConfig(); - new_win->setWindowTitle("配置"); - new_win->show(); + SetConfig * settingDlg = new SetConfig(); + settingDlg->setModal(true); + settingDlg->show(); } diff --git a/SetConfig.cpp b/SetConfig.cpp index 964bc9e..d9b6273 100644 --- a/SetConfig.cpp +++ b/SetConfig.cpp @@ -1,16 +1,42 @@ #include "SetConfig.h" #include "ui_SetConfig.h" -#include "QDebug" + +#include +#include +#include +#include + SetConfig::SetConfig(QWidget *parent) : QDialog(parent), ui(new Ui::SetConfig) { ui->setupUi(this); + + // 加载样式表 + QFile file(QApplication::applicationDirPath() + "/qss/dlgdark.css"); + if (file.open(QFile::ReadOnly)) { + QString qss = QLatin1String(file.readAll()); + this->setStyleSheet(qss); + file.close(); + } + init(); } void SetConfig::init() { - ui->IPInput->setText(SettingConfig::getInstance().DEVICE_HOST); + setAttribute(Qt::WA_DeleteOnClose); // 窗口关闭后释放本对象 + + setWindowFlags(Qt::Window | Qt::FramelessWindowHint + | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint + | Qt::WindowMaximizeButtonHint); + + this->setProperty("dialog", true); + + // 修改名称 + ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定"); + ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消"); + + ui->ipInput->setText(SettingConfig::getInstance().DEVICE_HOST); ui->devInput->setText(QString::number(SettingConfig::getInstance().DEVICE_PORT)); ui->listenInput->setText(QString::number(SettingConfig::getInstance().LISTEN_PORT)); ui->logInput->setText(SettingConfig::getInstance().BASE_LOG_PATH); @@ -22,7 +48,7 @@ void SetConfig::on_buttonBox_accepted() { - SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->IPInput->text()); + SettingConfig::getInstance().setConProperty("net", "deviceHost", ui->ipInput->text()); SettingConfig::getInstance().setConProperty("net", "devicePort", ui->devInput->text()); SettingConfig::getInstance().setConProperty("net", "listenPort", ui->listenInput->text()); SettingConfig::getInstance().setConProperty("log", "basePath", ui->logInput->text()); diff --git a/SetConfig.ui b/SetConfig.ui index 5697653..c17a73e 100644 --- a/SetConfig.ui +++ b/SetConfig.ui @@ -17,7 +17,7 @@ 30 - 241 + 250 341 31 @@ -27,6 +27,9 @@ 10 + + background-color: rgb(47, 53, 66); + Qt::Horizontal @@ -37,11 +40,11 @@ false - + 20 - 30 + 50 101 181 @@ -59,7 +62,7 @@ IP: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -75,7 +78,7 @@ 设备端口: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -91,7 +94,7 @@ 监听端口: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -107,24 +110,24 @@ 日志地址: - Qt::AlignCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 120 - 30 + 50 261 181 - + 0 @@ -181,10 +184,48 @@ 11 + + false + + + + + 20 + 5 + 80 + 30 + + + + + 微软雅黑 + 12 + + + + 系统设置 + + + + + + 1 + 45 + 398 + 3 + + + + QFrame::Plain + + + Qt::Horizontal + + diff --git a/qss/dlgdark.css b/qss/dlgdark.css new file mode 100644 index 0000000..c28364f --- /dev/null +++ b/qss/dlgdark.css @@ -0,0 +1,16 @@ +QDialog[dialog="true"] { + background: #666666; + border: 1px solid #2f3542; + border-radius: 0px; +} + +QWidget#inputWgt QLineEdit { + background: #2f3542; + color: #e8eaee; + border:1px solid #57606f; + border-radius: 4px; +} + +QDialogButtonBox#buttonBox { + background: #2f3542; +} \ No newline at end of file diff --git a/qss/pmdark.css b/qss/pmdark.css index de5e295..c83b18d 100644 --- a/qss/pmdark.css +++ b/qss/pmdark.css @@ -1,4 +1,4 @@ -QPalette{background:#444444;}*{outline:0px;color:#DCDCDC;} +QPalette{background:#444444;}*{outline:0px;color:#DCDCDC;} QWidget[form="true"] { background: #444444; @@ -7,26 +7,26 @@ } QWidget[form="title"] QLabel{ - border-radius:0px; - color:#DCDCDC; - background:none; - border-style:none; + border-radius:0px; + color:#DCDCDC; + background:none; + border-style:none; } QWidget[form="title"],QWidget[nav="left"],QWidget[nav="top"] QAbstractButton{ - border-style:none; - border-radius:0px; - padding:5px; - color:#DCDCDC; - background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); + border-style:none; + border-radius:0px; + padding:5px; + color:#DCDCDC; + background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); } QWidget[nav="top"] QAbstractButton:hover,QWidget[nav="top"] QAbstractButton:pressed{ - border-style:solid; - border-width:0px 0px 2px 0px; - padding:4px 4px 2px 4px; - border-color:#00BB9E; - background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); + border-style:solid; + border-width:0px 0px 2px 0px; + padding:4px 4px 2px 4px; + border-color:#00BB9E; + background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); } QPushButton#btnMenuMin,QPushButton#btnMenuClose{ @@ -44,61 +44,95 @@ background-color:rgba(51,127,209,230); } -QPushButton#btnMenuClose:hover{ +QPushButton#btnMenuClose:hover, QPushButton#closeButt:hover{ color:#FFFFFF; margin:1px 1px 2px 1px; background-color:rgba(238,0,0,128); } +QWidget#data QSpinBox#delay { + background-color: #2f3542; + height: 30px; + border:1px solid #57606f; + border-radius:4px; +} + +QWidget[form="channel"] QPushButton{ + border-radius:4px; + padding:5px; + color:#DCDCDC; + background: #57606f; +} +QWidget[form="channel"] QPushButton:hover{ + background: #a4b0be; +} + QScrollBar:vertical { width:8px; background:rgba(0,0,0,0%); margin:0px,0px,0px,0px; - padding-top:12px; + padding-top:12px; padding-bottom:12px; } QScrollBar::handle:vertical { width:8px; background:rgba(0,0,0,25%); - border-radius:4px; + border-radius:4px; min-height:20; } QScrollBar::handle:vertical:hover { width:8px; - background:rgba(0,0,0,50%); + background:rgba(0,0,0,50%); border-radius:4px; min-height:20; } -QScrollBar::add-line:vertical +QScrollBar::add-line:vertical { height:12px;width:12px; border-image:url(:/css/images/add_bottom.png); subcontrol-position:bottom; } -QScrollBar::sub-line:vertical +QScrollBar::sub-line:vertical { height:12px;width:12px; border-image:url(:/css/images/add_top.png); subcontrol-position:top; } -QScrollBar::add-line:vertical:hover +QScrollBar::add-line:vertical:hover { height:12px;width:12px; border-image:url(:/css/images/add_bottom.png); subcontrol-position:bottom; } -QScrollBar::sub-line:vertical:hover +QScrollBar::sub-line:vertical:hover { height:12px;width:12px; border-image:url(:/css/images/add_top.png); subcontrol-position:top; } -QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical +QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical { background:rgba(0,0,0,10%); border-radius:4px; } + +QMessageBox { + background-color: #666666; + border-radius: 3px; + width: 300px; + height: 300px; +} + +QMessageBox QLabel#qt_msgbox_label { /* textLabel */ + color: rgba(255, 255, 255, 1); + font: 16px "Microsoft YaHei"; + background-color: transparent; +} + +QMessageBox QPushButton { + background-color: rgb(47, 53, 66); +}