Move cache plot widget to CacheWidget
MODIFY
src/cachesim/cacheconfigwidget.cpp
src/cachesim/cacheconfigwidget.cpp
@@ -26,10 +26,6 @@ void CacheConfigWidget::setCache(std::shared_ptr<CacheSim>& cache) {
const QIcon sizeBreakdownIcon = QIcon(":/icons/info.svg");
m_ui->sizeBreakdownButton->setIcon(sizeBreakdownIcon);
- const QIcon plotIcon = QIcon(":/icons/analytics.svg");
- m_ui->cachePlot->setIcon(plotIcon);
- connect(m_ui->cachePlot, &QPushButton::clicked, this, &CacheConfigWidget::showCachePlot);
-
setupEnumCombobox(m_ui->replacementPolicy, s_cacheReplPolicyStrings);
setupEnumCombobox(m_ui->wrHit, s_cacheWritePolicyStrings);
setupEnumCombobox(m_ui->wrMiss, s_cacheWriteAllocateStrings);
@@ -65,11 +61,6 @@ void CacheConfigWidget::setCache(std::shared_ptr<CacheSim>& cache) {
handleConfigurationChanged();
}
-void CacheConfigWidget::showCachePlot() {
- CachePlotWidget plotWidget(*m_cache);
- plotWidget.exec();
-}
-
void CacheConfigWidget::setupPresets() {
std::vector<std::pair<QString, CacheSim::CachePreset>> presets;

MODIFY
src/cachesim/cacheconfigwidget.h
src/cachesim/cacheconfigwidget.h
@@ -24,7 +24,6 @@ signals:
public slots:
void updateHitrate();
void handleConfigurationChanged();
- void showCachePlot();
private:
void updateCacheSize();

MODIFY
src/cachesim/cacheconfigwidget.ui
src/cachesim/cacheconfigwidget.ui
<rect>
<x>0</x>
<y>0</y>
- <width>684</width>
+ <width>637</width>
<height>239</height>
</rect>
</property>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QToolButton" name="cachePlot">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- <property name="iconSize">
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- </widget>
- </item>
<item>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">

MODIFY
src/cachesim/cacheplotwidget.cpp
src/cachesim/cacheplotwidget.cpp
@@ -61,8 +61,7 @@ void finishSeries(QLineSeries& series, const unsigned max) {
namespace Ripes {
-CachePlotWidget::CachePlotWidget(const CacheSim& sim, QWidget* parent)
- : QDialog(parent), m_ui(new Ui::CachePlotWidget), m_cache(sim) {
+CachePlotWidget::CachePlotWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::CachePlotWidget) {
m_ui->setupUi(this);
setWindowTitle("Cache Access Statistics");
@@ -92,6 +91,10 @@ CachePlotWidget::CachePlotWidget(const CacheSim& sim, QWidget* parent)
connect(m_ui->plotType, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&CachePlotWidget::plotTypeChanged);
+}
+
+void CachePlotWidget::setCache(std::shared_ptr<CacheSim> cache) {
+ m_cache = cache;
// Synchronize widget state
plotTypeChanged();
@@ -239,7 +242,7 @@ void CachePlotWidget::variablesChanged() {
std::map<CachePlotWidget::Variable, QList<QPoint>>
CachePlotWidget::gatherData(const std::vector<Variable>& types) const {
- const auto& trace = m_cache.getAccessTrace();
+ const auto& trace = m_cache->getAccessTrace();
std::map<Variable, QList<QPoint>> cacheData;

MODIFY
src/cachesim/cacheplotwidget.h
src/cachesim/cacheplotwidget.h
#pragma once
-#include <QDialog>
#include <QMetaType>
+#include <QWidget>
#include <QtCharts/QChartGlobal>
#include "cachesim.h"
@@ -22,13 +22,14 @@ namespace Ui {
class CachePlotWidget;
}
-class CachePlotWidget : public QDialog {
+class CachePlotWidget : public QWidget {
Q_OBJECT
public:
enum Variable { Writes = 0, Reads, Hits, Misses, Writebacks, Accesses, N_Variables };
enum class PlotType { Ratio, Stacked };
- explicit CachePlotWidget(const CacheSim& sim, QWidget* parent = nullptr);
+ explicit CachePlotWidget(QWidget* parent = nullptr);
+ void setCache(std::shared_ptr<CacheSim> cache);
~CachePlotWidget();
public slots:
@@ -58,7 +59,7 @@ private:
QChart* m_currentPlot = nullptr;
Ui::CachePlotWidget* m_ui;
- const CacheSim& m_cache;
+ std::shared_ptr<CacheSim> m_cache;
QToolBar* m_toolbar = nullptr;
QAction* m_copyDataAction = nullptr;

MODIFY
src/cachesim/cacheplotwidget.ui
src/cachesim/cacheplotwidget.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ripes::CachePlotWidget</class>
- <widget class="QDialog" name="Ripes::CachePlotWidget">
+ <widget class="QWidget" name="Ripes::CachePlotWidget">
<property name="geometry">
<rect>
<x>0</x>

MODIFY
src/cachesim/cachewidget.cpp
src/cachesim/cachewidget.cpp
@@ -16,6 +16,7 @@ CacheWidget::CacheWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::CacheW
m_scene = std::make_unique<QGraphicsScene>(this);
m_cacheSim = std::make_shared<CacheSim>(this);
m_ui->cacheConfig->setCache(m_cacheSim);
+ m_ui->cachePlot->setCache(m_cacheSim);
auto* cacheGraphic = new CacheGraphic(*m_cacheSim);
m_scene->addItem(cacheGraphic);

MODIFY
src/cachesim/cachewidget.ui
src/cachesim/cachewidget.ui
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout" stretch="0">
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
<item>
<widget class="CacheConfigWidget" name="cacheConfig" native="true">
<property name="sizePolicy">
</property>
</widget>
</item>
+ <item>
+ <widget class="CachePlotWidget" name="cachePlot" native="true"/>
+ </item>
</layout>
</item>
</layout>
<header>cachesim/cacheconfigwidget.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>CachePlotWidget</class>
+ <extends>QWidget</extends>
+ <header>cachesim/cacheplotwidget.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>

Move cache plot widget to CacheWidget