@@ -409,25 +409,12 @@ void KsGLWidget::keyReleaseEvent(QKeyEvent *event)
*/
#define KS_MAX_START_PLOTS 16
-/**
- * @brief Load and show trace data.
- *
- * @param data: Input location for the KsDataStore object.
- * KsDataStore::loadDataFile() must be called first.
- */
-void KsGLWidget::loadData(KsDataStore *data)
+void KsGLWidget::_defaultPlots(kshark_context *kshark_ctx)
{
- kshark_context *kshark_ctx(nullptr);
QVector<int> streamIds, plotVec;
uint64_t tMin, tMax;
int nCPUs, nBins;
- if (!kshark_instance(&kshark_ctx) || !kshark_ctx->n_streams)
- return;
-
- loadColors();
-
- _data = data;
_model.reset();
_streamPlots.clear();
@@ -463,6 +450,31 @@ void KsGLWidget::loadData(KsDataStore *data)
tMin = _data->rows()[0]->ts;
tMax = _data->rows()[_data->size() - 1]->ts;
ksmodel_set_bining(_model.histo(), nBins, tMin, tMax);
+}
+
+/**
+ * @brief Load and show trace data.
+ *
+ * @param data: Input location for the KsDataStore object.
+ * KsDataStore::loadDataFile() must be called first.
+ * @param resetPlots: If true, all existing graphs are closed
+ * and a default configuration of graphs is displayed
+ * (all CPU plots). If false, the current set of graphs
+ * is preserved.
+ */
+void KsGLWidget::loadData(KsDataStore *data, bool resetPlots)
+{
+ kshark_context *kshark_ctx(nullptr);
+
+ if (!kshark_instance(&kshark_ctx) || !kshark_ctx->n_streams)
+ return;
+
+ loadColors();
+
+ _data = data;
+ if (resetPlots)
+ _defaultPlots(kshark_ctx);
+
_model.fill(_data);
}
@@ -101,7 +101,7 @@ public:
void keyReleaseEvent(QKeyEvent *event);
- void loadData(KsDataStore *data);
+ void loadData(KsDataStore *data, bool resetPlots);
void loadColors();
@@ -326,6 +326,8 @@ private:
int _getLastCPU(struct kshark_trace_histo *histo,
int bin, int sd, int pid);
+ void _defaultPlots(kshark_context *kshark_ctx);
+
void _deselect();
int _bin0Offset() {return _labelSize + 2 * _hMargin;}
@@ -1283,7 +1283,8 @@ void KsMainWindow::_load(const QString& fileName, bool append)
QApplication::processEvents();
_view.reset();
- _graph.reset();
+ if (!append)
+ _graph.reset();
auto lamLoadJob = [&, this] () {
QVector<kshark_dpi *> v;
@@ -1333,7 +1334,10 @@ void KsMainWindow::_load(const QString& fileName, bool append)
_view.loadData(&_data);
pb.setValue(175);
- _graph.loadData(&_data);
+ _graph.loadData(&_data, !append);
+ if (append)
+ _graph.cpuReDraw(sd, KsUtils::getCPUList(sd));
+
pb.setValue(195);
}
@@ -1454,7 +1458,7 @@ void KsMainWindow::loadSession(const QString &fileName)
_view.loadData(&_data);
pb.setValue(155);
- _graph.loadData(&_data);
+ _graph.loadData(&_data, true);
_filterSyncCBoxUpdate(kshark_ctx);
pb.setValue(175);
@@ -148,12 +148,16 @@ KsTraceGraph::KsTraceGraph(QWidget *parent)
* @brief Load and show trace data.
*
* @param data: Input location for the KsDataStore object.
- * KsDataStore::loadDataFile() must be called first.
+ * KsDataStore::loadDataFile() must be called first.
+ * @param resetPlots: If true, all existing graphs are closed
+ * and a default configuration of graphs is displayed
+ * (all CPU plots). If false, the current set of graphs
+ * is preserved.
*/
-void KsTraceGraph::loadData(KsDataStore *data)
+void KsTraceGraph::loadData(KsDataStore *data, bool resetPlots)
{
_data = data;
- _glWindow.loadData(data);
+ _glWindow.loadData(data, resetPlots);
updateGeom();
}
@@ -45,7 +45,7 @@ class KsTraceGraph : public KsWidgetsLib::KsDataWidget
public:
explicit KsTraceGraph(QWidget *parent = nullptr);
- void loadData(KsDataStore *data);
+ void loadData(KsDataStore *data, bool resetPlots);
void setMarkerSM(KsDualMarkerSM *m);
@@ -785,6 +785,7 @@ int KsDataStore::appendDataFile(const QString &file, int64_t offset)
_rows = mergedRows;
registerCPUCollections();
+ emit updateWidgets(this);
return sd;
}
If the user has already made some selection of graphs to be displayed by the GUI, those particular graphs are likely to be important for him, so it is better to keep this configuration after the data file is appended. The opposite can be annoying for the user. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/KsGLWidget.cpp | 40 ++++++++++++++++++++++++++-------------- src/KsGLWidget.hpp | 4 +++- src/KsMainWindow.cpp | 10 +++++++--- src/KsTraceGraph.cpp | 10 +++++++--- src/KsTraceGraph.hpp | 2 +- src/KsUtils.cpp | 1 + 6 files changed, 45 insertions(+), 22 deletions(-)