diff --git a/editprofile.cpp b/editprofile.cpp index 7e8b0db..8b5181b 100644 --- a/editprofile.cpp +++ b/editprofile.cpp @@ -8,6 +8,19 @@ editProfile::editProfile(QWidget *parent) : { ui->setupUi(this); + // Get the main widget backgorund palette and use the colors for the plots + QPalette palette; + palette.setCurrentColorGroup(QPalette::Active); + QColor color = palette.color(QPalette::Background); + QColor textColor = palette.color(QPalette::Text); + QColor graphColor = palette.color(QPalette::Highlight); + QPen graphPen; + graphPen.setWidth(2); + graphPen.setColor(graphColor); + QPen tickPen; + tickPen.setWidthF(0.5); + tickPen.setColor(textColor); + // Define the filler line vectors and graphs so they don't need to be recreated every update leftLineX.append(x_lower); leftLineX.append(0); @@ -26,8 +39,20 @@ editProfile::editProfile(QWidget *parent) : ui->curvePlot->graph(0)->setScatterStyle(QCPScatterStyle::ssCircle); ui->curvePlot->graph(0)->setLineStyle(QCPGraph::lsLine); - //ui->curvePlot->setInteractions(QCP::iSelectItems | QCP::iSelectPlottables); - //ui->curvePlot->graph(0)->setSelectable(QCP::SelectionType::stSingleData); + ui->curvePlot->setBackground(color); + ui->curvePlot->xAxis->setLabelColor(textColor); + ui->curvePlot->yAxis->setLabelColor(textColor); + ui->curvePlot->xAxis->setTickLabelColor(textColor); + ui->curvePlot->yAxis->setTickLabelColor(textColor); + ui->curvePlot->graph(0)->setPen(graphPen); + ui->curvePlot->graph(1)->setPen(graphPen); + ui->curvePlot->graph(2)->setPen(graphPen); + ui->curvePlot->xAxis->setTickPen(tickPen); + ui->curvePlot->yAxis->setTickPen(tickPen); + ui->curvePlot->xAxis->setSubTickPen(tickPen); + ui->curvePlot->yAxis->setSubTickPen(tickPen); + ui->curvePlot->xAxis->setBasePen(tickPen); + ui->curvePlot->yAxis->setBasePen(tickPen); ui->curvePlot->xAxis->setLabel("Temperature"); ui->curvePlot->yAxis->setLabel("Fan speed (%)"); @@ -253,6 +278,10 @@ void editProfile::dragPoint(int index_x, int index_y, QMouseEvent* event) void editProfile::drawCoordtext() { + QPalette palette; + palette.setCurrentColorGroup(QPalette::Active); + QColor textColor = palette.color(QPalette::Text); + QCPItemText *coordText = new QCPItemText(ui->curvePlot); if (draggingPoint) { if (qv_x[index_x] > x_upper) { @@ -272,6 +301,7 @@ void editProfile::drawCoordtext() QString xString = QString::number(qv_x[index_x]); QString yString = QString::number(qv_y[index_y]); coordText->setText(xString + ", " + yString); + coordText->setColor(textColor); } else { ui->curvePlot->removeItem(coordText); diff --git a/mainwindow.cpp b/mainwindow.cpp index 2a86795..27e0bbf 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -148,6 +148,8 @@ void MainWindow::setupGraphMonitorTab() plotCmdsList.append(coreclkplot); plotCmdsList.append(memclkplot); plotCmdsList.append(coreutilplot); + plotCmdsList.append(memutilplot); + plotCmdsList.append(voltageplot); // Layout for the plots plotWidget->setLayout(plotLayout); @@ -181,11 +183,23 @@ void MainWindow::setupGraphMonitorTab() plotCmdsList[4].layout = coreUtilLayout; plotCmdsList[4].widget = coreUtilWidget; + plotCmdsList[5].plot = memUtilPlot; + plotCmdsList[5].vector = qv_memUtil; + plotCmdsList[5].layout = memUtilLayout; + plotCmdsList[5].widget = memUtilWidget; + + plotCmdsList[6].plot = voltagePlot; + plotCmdsList[6].vector = qv_voltage; + plotCmdsList[6].layout = voltageLayout; + plotCmdsList[6].widget = voltageWidget; + plotCmdsList[0].valueq = mon.temp.toDouble(); plotCmdsList[1].valueq = mon.powerdraw.toDouble(); plotCmdsList[2].valueq = mon.coreclock.toDouble(); plotCmdsList[3].valueq = mon.memclock.toDouble(); plotCmdsList[4].valueq = mon.coreutil.toDouble(); + plotCmdsList[5].valueq = mon.memutil.toDouble(); + plotCmdsList[6].valueq = mon.voltage.toDouble(); // Get the main widget backgorund palette and use the colors for the plots QPalette palette; palette.setCurrentColorGroup(QPalette::Active); @@ -229,23 +243,17 @@ void MainWindow::setupGraphMonitorTab() // Set the y-range plotCmdsList[i].plot->yAxis->setRange(plotCmdsList[i].valueq -plotCmdsList[i].valueq*0.1, plotCmdsList[i].valueq + plotCmdsList[i].valueq*0.1); - connect(plotCmdsList[i].plot, SIGNAL(mouseMove(QMouseEvent*)), SLOT(plotHovered(QMouseEvent*))); + //connect(plotCmdsList[i].plot, SIGNAL(mouseMove(QMouseEvent*)), SLOT(plotHovered(QMouseEvent*))); + //connect(plotCmdsList[i].widget, SIGNAL(mouseEnterEvent(QEvent*)), SLOT(plotHovered())); } tempPlot->yAxis->setLabel("Temperature (°C)"); - //tempPlot->yAxis->setRange(0, 90); - powerDrawPlot->yAxis->setLabel("Power Draw (W)"); - //powerDrawPlot->yAxis->setRange(0, curPowerLimInt); - coreClkPlot->yAxis->setLabel("Core Clock Frequency (MHz)"); - //coreClkPlot->yAxis->setRange(100, curMaxClkInt); - memClkPlot->yAxis->setLabel("Memory Clock Frequency (MHz)"); - //memClkPlot->yAxis->setRange(100, curMaxMemClkInt); - coreUtilPlot->yAxis->setLabel("Core Utilization (%)"); - //coreUtilPlot->yAxis->setRange(0, 100); + memUtilPlot->yAxis->setLabel("Memory Utilization (%)"); + voltagePlot->yAxis->setLabel("Core Voltage (mV)"); plotScrollArea->setWidget(plotWidget); plotScrollArea->setWidgetResizable(true); @@ -253,6 +261,8 @@ void MainWindow::setupGraphMonitorTab() // Add scroll area to a layout so we can set it as the widget for the tab lo->addWidget(plotScrollArea); ui->monitorTab->setLayout(lo); + + connect(plotHoverUpdater, SIGNAL(timeout()), SLOT(plotHovered())); } void MainWindow::updateMonitor() { @@ -264,7 +274,7 @@ void MainWindow::updateMonitor() coreclock->setText(1, mon.coreclock + " MHz"); memclock->setText(1, mon.memclock + " MHz"); coreutil->setText(1, mon.coreutil + " %"); - memutil->setText(1, mon.memutil); + memutil->setText(1, mon.memutil + " %"); fanspeed->setText(1, QString::number(fanSpeed) + " %"); memusage->setText(1, mon.usedmem + "/" + mon.totalmem); @@ -289,6 +299,8 @@ void MainWindow::updateMonitor() plotCmdsList[2].valueq = mon.coreclock.toDouble(); plotCmdsList[3].valueq = mon.memclock.toDouble(); plotCmdsList[4].valueq = mon.coreutil.toDouble(); + plotCmdsList[5].valueq = mon.memutil.toDouble(); + plotCmdsList[6].valueq = mon.voltage.toDouble(); for (int i=0; igraph(0)->setData(qv_time, plotCmdsList[i].vector); // If the newest value is out of bounds, resize the y-range - qDebug() << plotCmdsList[i].plot->xAxis->range().upper; if (plotCmdsList[i].valueq > plotCmdsList[i].plot->yAxis->range().upper) { plotCmdsList[i].plot->yAxis->setRangeUpper(plotCmdsList[i].valueq + plotCmdsList[i].valueq*0.1); } if (plotCmdsList[i].valueq < plotCmdsList[i].plot->yAxis->range().lower) { plotCmdsList[i].plot->yAxis->setRangeLower(plotCmdsList[i].valueq - plotCmdsList[i].valueq*0.1); } - qDebug() << counter; plotCmdsList[i].plot->replot(); plotCmdsList[i].plot->update(); - } - // If the largest/smallest values are too close to the range end, this will resize them every 10th iteration of this function + } + // If the largest/smallest value is too far from the range end, this resizes them every 10th iteration of this function if (counter >= 10) { for (int i=0; istart(1000); QPoint cursor = event->pos(); + //qDebug() << childAt(cursor); //QWidget *widget = childAt(cursor); //QCustomPlot *plot = widget->findChild(QString(), Qt::FindDirectChildrenOnly); //plot->xAxis->setRange(-15, 0); + + int plotIndex = 0; + for (int i=0; iunderMouse()) { + plotIndex = i; + break; + } + } + int xindex = round(plotCmdsList[plotIndex].plot->xAxis->pixelToCoord(cursor.x())) + plotCmdsList[plotIndex].vector.size(); + + // Find the y-value for the corresponding coordinate + double ycoord = plotCmdsList[plotIndex].vector[xindex]; + qDebug() << ycoord; } void MainWindow::checkForProfiles() { @@ -878,6 +903,7 @@ void MainWindow::on_editFanCurveButton_pressed() connect(editProf, SIGNAL(destroyed(QObject*)), SLOT(on_editProfile_closed())); editProf->setModal(true); editProf->exec(); + } void MainWindow::on_editProfile_closed() { diff --git a/mainwindow.h b/mainwindow.h index 76a187b..05afb63 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -158,6 +158,7 @@ private: QTimer *statusLabelResetTimer = new QTimer(this); QTimer *fanUpdaterDisablerTimer = new QTimer(this); QTimer *monitorUpdater = new QTimer(this); + QTimer *plotHoverUpdater = new QTimer(this); QTreeWidgetItem *gputemp = new QTreeWidgetItem; QTreeWidgetItem *powerdraw = new QTreeWidgetItem; @@ -183,20 +184,26 @@ private: QVBoxLayout *coreClkLayout = new QVBoxLayout; QVBoxLayout *memClkLayout = new QVBoxLayout; QVBoxLayout *coreUtilLayout = new QVBoxLayout; + QVBoxLayout *memUtilLayout = new QVBoxLayout; + QVBoxLayout *voltageLayout = new QVBoxLayout; QCustomPlot *tempPlot = new QCustomPlot; QCustomPlot *powerDrawPlot = new QCustomPlot; QCustomPlot *coreClkPlot = new QCustomPlot; QCustomPlot *memClkPlot = new QCustomPlot; QCustomPlot *coreUtilPlot = new QCustomPlot; + QCustomPlot *memUtilPlot = new QCustomPlot; + QCustomPlot *voltagePlot = new QCustomPlot; QWidget *tempWidget = new QWidget; QWidget *powerDrawWidget = new QWidget; QWidget *coreClkWidget = new QWidget; QWidget *memClkWidget = new QWidget; QWidget *coreUtilWidget = new QWidget; + QWidget *memUtilWidget = new QWidget; + QWidget *voltageWidget = new QWidget; - QVector qv_time, qv_temp, qv_powerDraw, qv_coreClk, qv_memClk, qv_coreUtil; + QVector qv_time, qv_temp, qv_powerDraw, qv_coreClk, qv_memClk, qv_coreUtil, qv_memUtil, qv_voltage; double tempnum; double powernum = 0; struct plotCmds @@ -214,6 +221,8 @@ private: plotCmds coreclkplot; plotCmds memclkplot; plotCmds coreutilplot; + plotCmds memutilplot; + plotCmds voltageplot; QVector plotCmdsList; }; #endif // MAINWINDOW_H diff --git a/monitor.h b/monitor.h index 7902887..1592e25 100644 --- a/monitor.h +++ b/monitor.h @@ -25,7 +25,7 @@ public: QString nvCoreClkQ = "nvidia-smi --query-gpu=clocks.gr --format=csv,noheader,nounits"; QString nvMemClkQ = "nvidia-smi --query-gpu=clocks.mem --format=csv,noheader,nounits"; QString nvCoreUtilQ = "nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits"; - QString nvMemUtilQ = "nvidia-smi --query-gpu=utilization.memory --format=csv,noheader"; + QString nvMemUtilQ = "nvidia-smi --query-gpu=utilization.memory --format=csv,noheader,nounits"; QString nvUsedMemQ = "nvidia-smi --query-gpu=memory.used --format=csv,noheader"; QString nvTotalMemQ = "nvidia-smi --query-gpu=memory.total --format=csv,noheader"; QString nvCurMaxClkQ = "nvidia-smi --query-supported-clocks=gr --format=csv,noheader";