aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/qt/io_graph_dialog.cpp63
-rw-r--r--ui/qt/io_graph_dialog.h1
2 files changed, 50 insertions, 14 deletions
diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp
index 2a03504f78..e763978db5 100644
--- a/ui/qt/io_graph_dialog.cpp
+++ b/ui/qt/io_graph_dialog.cpp
@@ -1934,17 +1934,8 @@ void IOGraph::recalcGraphData(capture_file *cap_file, bool enable_scaling)
ts += start_time_;
}
double val = getItemValue(i, cap_file);
- // Should we show this value? Yes, if
- // - It's for a line or bar graph
- // - It's a scatter plot with a calculated value.
- bool show_value = val != 0.0 || (graph_ && graph_->scatterStyle().shape() == QCPScatterStyle::ssNone);
-
- if (val_units_ >= IOG_ITEM_UNIT_CALC_SUM) {
- show_value = true;
- }
if (moving_avg_period_ > 0) {
- show_value = true;
if (i != 0) {
mavg_left++;
if (mavg_left > moving_avg_period_ / 2) {
@@ -1966,11 +1957,14 @@ void IOGraph::recalcGraphData(capture_file *cap_file, bool enable_scaling)
}
}
- if (graph_ && show_value) {
- graph_->addData(ts, val);
- }
- if (bars_) {
- bars_->addData(ts, val);
+ if (hasItemToShow(i, val))
+ {
+ if (graph_) {
+ graph_->addData(ts, val);
+ }
+ if (bars_) {
+ bars_->addData(ts, val);
+ }
}
// qDebug() << "=rgd i" << i << ts << val;
}
@@ -2082,6 +2076,47 @@ void IOGraph::reloadValueUnitField()
}
}
+// Check if a packet is available at the given interval (idx).
+bool IOGraph::hasItemToShow(int idx, double value) const
+{
+ g_assert(idx < max_io_items_);
+
+ bool result = false;
+
+ const io_graph_item_t *item = &items_[idx];
+
+ switch (val_units_) {
+ case IOG_ITEM_UNIT_PACKETS:
+ case IOG_ITEM_UNIT_BYTES:
+ case IOG_ITEM_UNIT_BITS:
+ case IOG_ITEM_UNIT_CALC_FRAMES:
+ case IOG_ITEM_UNIT_CALC_FIELDS:
+ if(value == 0.0 && (graph_ && graph_->scatterStyle().shape() != QCPScatterStyle::ssNone)) {
+ result = false;
+ }
+ else {
+ result = true;
+ }
+ break;
+
+ case IOG_ITEM_UNIT_CALC_SUM:
+ case IOG_ITEM_UNIT_CALC_MAX:
+ case IOG_ITEM_UNIT_CALC_MIN:
+ case IOG_ITEM_UNIT_CALC_AVERAGE:
+ case IOG_ITEM_UNIT_CALC_LOAD:
+ if (item->fields) {
+ result = true;
+ }
+ break;
+
+ default:
+ result = true;
+ break;
+ }
+
+ return result;
+}
+
void IOGraph::setInterval(int interval)
{
interval_ = interval;
diff --git a/ui/qt/io_graph_dialog.h b/ui/qt/io_graph_dialog.h
index b29c17845c..d2392029b6 100644
--- a/ui/qt/io_graph_dialog.h
+++ b/ui/qt/io_graph_dialog.h
@@ -72,6 +72,7 @@ public:
QCPBars *bars() { return bars_; }
double startOffset();
int packetFromTime(double ts);
+ bool hasItemToShow(int idx, double value) const;
double getItemValue(int idx, const capture_file *cap_file) const;
int maxInterval () const { return cur_idx_; }
QString scaledValueUnit() const { return scaled_value_unit_; }