命名审查与垃圾代码清理(纯重命名 / 死代码删除,无行为变更)

前提:加载完成后全部采样都已驻留内存,程序此后与源文件再无联系。
据此修正了一批会让人误以为"仍在读写文件"的命名:

- SampleFileAt → SampleSignalAt(取的是内存信号在给定时刻的采样值)。
- DataSet::AddPreparedFile → AddDataFile。
- PlotView::InvalidatePolylineCache → InvalidateDerivedCaches
  (它同时清空折线、边沿统计、中心平均值曲线、静态场景缓存与悬停引用)。
- PlotView::CursorColor(int which) → CursorColor()(两条光标同色,参数从未使用)。
- UiEllipsize(g,…) → UiEllipsize(…):纯测量不绘制,删掉被忽略的绘图上下文参数;
  同时删除与 UiMeasureTextWidth 完全重复的 UiTextWidth,调用点统一到 UiMeasureTextWidth。

清理残留参数((void)xxx;):
- TabConfig 的可见性/网格族(SetVisible / ToggleVisible / SetFileVisible / SetAllVisible /
  SoloSignal / SetMode / SyncLanes / FileHasVisible / FileAllVisible)去掉从未使用的
  const DataSet& 参数(仅 SyncToDataSet 真正需要数据层,保留)。
- PlotView::OnLButtonUp(int y)、OnMouseWheel(int delta, bool shift);PainterSignalHalo 去掉未用的 ref。
- BuildDataFile 中未使用的局部 rowCount。

删除无人调用的死函数:
  DataSet::Clear / AddFromTable;SignalColorCount;WideToUtf8 / StartsWith;
  PlotView::ViewMinTime / ViewMaxTime / EdgePanelRect / EdgePanelCloseRect /
  EdgeCenterPanelRect / ScaleLaneRange / BeginLaneValueEdit / LaneContentHeight;
  SignalPanel::NeedsScrollBar / IsFilterEditing / FilterText / ContentHeight;
  PopupMenu::EditingItemId;TabBar::IsDragging;TextEdit::PlaceCaret。

删除只写不读的死字段:CsvTable::sourceRowCount(与 rowCount 等义)与 skippedRowCount。

以 VERY_BIG_DATA.CSV 回归验证:加载与勾选、筛选框(含"无匹配的筛选信号")、
样式区线宽文案省略、选区放大(横向与纵向)、双光标读数与 Δt、右键菜单(Y 轴数值与
实验性功能子菜单)、合并/拆分网格、标签与信号重命名省略号,行为均与改动前一致;
make clean && make all 无任何警告。
This commit is contained in:
DeepSeek V4.1 Flash committed 2026-10-09 21:52:46 +08:00
1 parent f5028b1e18
commit 350538c634
21 files changed
+118 -456

No files matched your search

+29 -111
View File
@@ -363,7 +363,7 @@ namespace jdi
m_hoverLane = -1;
m_dragMode = PlotDragMode::NONE;
// 重新绑定数据源后旧的几何键不再有意义,必须清空折线缓存。
InvalidatePolylineCache();
InvalidateDerivedCaches();
InvalidateSceneCache();
RefreshLanes();
}
@@ -389,16 +389,6 @@ namespace jdi
return Tab().CursorMode();
}
double PlotView::ViewMinTime() const
{
return Tab().ViewMin();
}
double PlotView::ViewMaxTime() const
{
return Tab().ViewMax();
}
bool PlotView::HasDrawableContent() const
{
return (m_dataSet != nullptr) && !m_dataSet->Empty() && (m_tab != nullptr) && m_tab->AnyVisible();
@@ -899,10 +889,9 @@ namespace jdi
}
}
std::uint32_t PlotView::CursorColor(int which) const
std::uint32_t PlotView::CursorColor() const
{
// 两条光标统一使用同一样式与颜色(与光标 1 一致),不再按序号区分配色。
(void)which;
// 两条光标统一使用同一样式与颜色,不按序号区分配色。
if (m_theme == nullptr)
{
return 0xFF000000u;
@@ -952,7 +941,7 @@ namespace jdi
return true;
}
void PlotView::InvalidatePolylineCache()
void PlotView::InvalidateDerivedCaches()
{
m_polylineCache.clear();
// 数据层结构变化后边沿统计与中心平均值曲线的派生结果都会失效。
@@ -2080,37 +2069,6 @@ namespace jdi
}
}
void PlotView::ScaleLaneRange(int laneIndex, double factor, double anchorValue)
{
if (m_tab == nullptr || laneIndex < 0 || laneIndex >= static_cast<int>(m_lanes.size()))
{
return;
}
if (!(factor > 0.0) || !std::isfinite(anchorValue))
{
return;
}
const LaneVisual& visual = m_lanes[static_cast<std::size_t>(laneIndex)];
const double span = visual.yMax - visual.yMin;
if (!(span > 0.0))
{
return;
}
const double magnitude = std::max(std::fabs(visual.yMax), std::fabs(visual.yMin));
const double minSpan = std::max(magnitude * 1.0e-9, 1.0e-12);
const double newSpan = ClampDouble(span / factor, minSpan, magnitude * 100.0 + 1.0);
const double ratio = (visual.yMax - anchorValue) / span;
Lane& lane = m_tab->Lanes()[static_cast<std::size_t>(laneIndex)];
lane.autoRange = false;
lane.fitYToSelection = false;
lane.yMin = anchorValue - ratio * newSpan;
lane.yMax = lane.yMin + newSpan;
BuildLaneVisuals();
}
void PlotView::ShiftLaneRange(int laneIndex, double deltaValue)
{
if (m_tab == nullptr || laneIndex < 0 || laneIndex >= static_cast<int>(m_lanes.size()) ||
@@ -2135,27 +2093,6 @@ namespace jdi
BuildLaneVisuals();
}
bool PlotView::BeginLaneValueEdit(int laneIndex, bool editMax, const gd::RectF& anchorRect)
{
if (m_tab == nullptr || laneIndex < 0 || laneIndex >= static_cast<int>(m_tab->Lanes().size()))
{
return false;
}
if (m_lanes.empty())
{
BuildLaneVisuals();
}
if (laneIndex >= static_cast<int>(m_lanes.size()))
{
return false;
}
const LaneVisual& visual = m_lanes[static_cast<std::size_t>(laneIndex)];
const double current = editMax ? visual.yMax : visual.yMin;
return BeginEdit(editMax ? PlotEditTarget::LANE_Y_MAX : PlotEditTarget::LANE_Y_MIN, laneIndex,
FormatValue(current), anchorRect);
}
bool PlotView::ApplyLaneValueText(int laneIndex, bool editMax, const std::wstring& text)
{
if (m_tab == nullptr || laneIndex < 0 || laneIndex >= static_cast<int>(m_tab->Lanes().size()))
@@ -3468,8 +3405,9 @@ namespace jdi
return changed;
}
bool PlotView::OnLButtonUp(int x, int y)
{ bool changed = (m_dragMode != PlotDragMode::NONE);
bool PlotView::OnLButtonUp(int y)
{
bool changed = (m_dragMode != PlotDragMode::NONE);
switch (m_dragMode)
{
@@ -3528,11 +3466,10 @@ namespace jdi
m_edgePanelDragKind = EdgePanelKind::COUNT;
// 松开左键:粘滞提示结束计时,开始"停留后淡出"。
ReleaseHint();
(void)x;
return changed;
}
bool PlotView::OnMouseWheel(int x, int y, int delta, bool shift)
bool PlotView::OnMouseWheel(int delta, bool shift)
{
if (!HasDrawableContent() || delta == 0)
{
@@ -3559,8 +3496,6 @@ namespace jdi
Tab().LaneScroll() -= static_cast<float>(notches * 48.0 * m_scale);
BuildLaneVisuals();
(void)x;
(void)y;
return true;
}
@@ -4125,7 +4060,7 @@ namespace jdi
g.DrawRectangle(&borderPen, m_plotRect.X, m_plotRect.Y, m_plotRect.Width, m_plotRect.Height);
}
void PlotView::PaintSignalHalo(gd::Graphics& g, const SignalRef& ref, const ResolvedSignal& resolved,
void PlotView::PaintSignalHalo(gd::Graphics& g, const ResolvedSignal& resolved,
const std::vector<gd::PointF>& points,
const std::vector<std::size_t>& breaks)
{
@@ -4133,8 +4068,6 @@ namespace jdi
if (!drawLine || breaks.empty())
{
// 散点模式没有光晕(原实现同样只对折线绘制光晕)。
(void)g;
(void)ref;
return;
}
@@ -4194,7 +4127,7 @@ namespace jdi
const PolylineCacheEntry* cached = AcquirePolyline(m_hoverSignal, resolved, lane);
if (cached != nullptr)
{
PaintSignalHalo(g, m_hoverSignal, resolved, cached->points, cached->breaks);
PaintSignalHalo(g, resolved, cached->points, cached->breaks);
}
}
}
@@ -4534,7 +4467,7 @@ namespace jdi
return;
}
const float textWidth = UiTextWidth(g, text, m_fonts->monoSmall) + 12.0f * m_scale;
const float textWidth = UiMeasureTextWidth(m_fonts->monoSmall, text) + 12.0f * m_scale;
const float textHeight = 18.0f * m_scale;
float labelX = m_rubberRect.X + m_rubberRect.Width * 0.5f - textWidth * 0.5f;
labelX = std::max(m_plotRect.X, std::min(labelX, m_plotRect.X + m_plotRect.Width - textWidth));
@@ -4568,7 +4501,7 @@ namespace jdi
// 提示条贴在绘图区底部居中;时间光标的时间读数也在底部,
// 因此光标启用时把提示条上移一行,避免两者互相遮挡。
const float reserved = (m_tab != nullptr && Tab().CursorEnabled()) ? 26.0f * m_scale : 0.0f;
const float width = UiTextWidth(g, m_hintText, m_fonts->ui) + 30.0f * m_scale;
const float width = UiMeasureTextWidth(m_fonts->ui, m_hintText) + 30.0f * m_scale;
const float height = 30.0f * m_scale;
float left = m_plotRect.X + (m_plotRect.Width - width) * 0.5f;
left = std::max(m_plotRect.X + 2.0f * m_scale,
@@ -4731,7 +4664,7 @@ namespace jdi
const bool highlighted = (ref == haloRef);
if (highlighted)
{
PaintSignalHalo(g, ref, resolved, points, breaks);
PaintSignalHalo(g, resolved, points, breaks);
}
if (drawLine && !breaks.empty())
@@ -4892,7 +4825,7 @@ namespace jdi
}
UiFillRoundRect(g, pill, 3.0f * m_scale, WithAlpha(m_theme->cardBg, 0xF0));
const std::wstring text = UiEllipsize(g, raw, m_fonts->monoSmall, pill.Width - 6.0f * m_scale);
const std::wstring text = UiEllipsize(raw, m_fonts->monoSmall, pill.Width - 6.0f * m_scale);
UiText(g, text, m_fonts->monoSmall,
gd::RectF(pill.X + 4.0f * m_scale, pill.Y, pill.Width - 8.0f * m_scale, pill.Height),
(tick == 0.0) ? m_theme->text : m_theme->textMuted, TextAlign::LEFT);
@@ -4972,7 +4905,7 @@ namespace jdi
label += L" · " + resolved.file->Title();
}
const float itemWidth = kLegendSwatchSize * m_scale + 5.0f * m_scale +
std::min(UiTextWidth(g, label, m_fonts->uiSmall),
std::min(UiMeasureTextWidth(m_fonts->uiSmall, label),
kLegendMaxTextWidth * m_scale) +
kLegendItemGap * m_scale;
if (cursorX + legendWidth + itemWidth > maxX)
@@ -5027,10 +4960,10 @@ namespace jdi
}
// 文本宽度按上限夹取,超出部分用省略号(与测量阶段保持一致)。
const float maxTextWidth = kLegendMaxTextWidth * m_scale;
const float fullTextWidth = UiTextWidth(g, label, m_fonts->uiSmall);
const float fullTextWidth = UiMeasureTextWidth(m_fonts->uiSmall, label);
const float textWidth = std::min(fullTextWidth, maxTextWidth);
const std::wstring drawLabel =
(fullTextWidth > maxTextWidth) ? UiEllipsize(g, label, m_fonts->uiSmall, maxTextWidth) : label;
(fullTextWidth > maxTextWidth) ? UiEllipsize(label, m_fonts->uiSmall, maxTextWidth) : label;
const float itemWidth = kLegendSwatchSize * m_scale + 5.0f * m_scale + textWidth +
kLegendItemGap * m_scale;
if (drawnWidth + itemWidth > legendWidth + 0.5f)
@@ -5114,7 +5047,7 @@ namespace jdi
{
for (std::size_t fileIndex = 0; fileIndex < m_dataSet->FileCount(); ++fileIndex)
{
if (!m_tab->FileHasVisible(*m_dataSet, static_cast<int>(fileIndex)))
if (!m_tab->FileHasVisible(static_cast<int>(fileIndex)))
{
continue;
}
@@ -5138,7 +5071,7 @@ namespace jdi
m_plotRect.Width * 0.4f);
const gd::RectF nameRect(m_plotRect.X + 2.0f * m_scale, axisY + 3.0f * m_scale, nameWidth,
std::max(0.0f, m_timeAxisRect.Height - 5.0f * m_scale));
UiText(g, UiEllipsize(g, axisName, m_fonts->monoSmall, nameWidth), m_fonts->monoSmall, nameRect,
UiText(g, UiEllipsize(axisName, m_fonts->monoSmall, nameWidth), m_fonts->monoSmall, nameRect,
m_theme->textMuted, TextAlign::LEFT);
const float labelWidth = 96.0f * m_scale;
@@ -5295,7 +5228,7 @@ namespace jdi
}
const bool hot = (m_hoverCursor == which);
const std::uint32_t color = CursorColor(which);
const std::uint32_t color = CursorColor();
const float lineTop = m_plotRect.Y;
const float lineBottom = m_timeAxisRect.Y + m_timeAxisRect.Height;
UiDrawLine(g, x, lineTop, x, lineBottom, color, (hot ? 2.0f : 1.4f) * m_scale);
@@ -5346,7 +5279,7 @@ namespace jdi
const bool interpolate = (resolved.style->mode != DrawMode::SCATTER);
double value = 0.0;
if (!SampleFileAt(*resolved.file, *resolved.data, time, interpolate, value))
if (!SampleSignalAt(*resolved.file, *resolved.data, time, interpolate, value))
{
continue;
}
@@ -5368,7 +5301,7 @@ namespace jdi
if (showDelta)
{
double otherValue = 0.0;
if (SampleFileAt(*resolved.file, *resolved.data, otherTime, interpolate, otherValue))
if (SampleSignalAt(*resolved.file, *resolved.data, otherTime, interpolate, otherValue))
{
const double delta = value - otherValue;
// 增量 = 右侧光标取值 − 左侧光标取值,包在圆括号里并按差值显式给出正负号。
@@ -5379,7 +5312,7 @@ namespace jdi
}
}
const float textWidth = UiTextWidth(g, text, m_fonts->monoSmall) + 10.0f * m_scale;
const float textWidth = UiMeasureTextWidth(m_fonts->monoSmall, text) + 10.0f * m_scale;
const float textHeight = 17.0f * m_scale;
float labelLeft = pinX + radius + 4.0f * m_scale;
if (labelLeft + textWidth > m_plotRect.X + m_plotRect.Width - 2.0f * m_scale)
@@ -5454,7 +5387,7 @@ namespace jdi
centerText += L")";
const float centerTextWidth =
UiTextWidth(g, centerText, m_fonts->monoSmall) + 10.0f * m_scale;
UiMeasureTextWidth(m_fonts->monoSmall, centerText) + 10.0f * m_scale;
float centerLeft = pinX + radius + 4.0f * m_scale;
if (centerLeft + centerTextWidth >
m_plotRect.X + m_plotRect.Width - 2.0f * m_scale)
@@ -5507,7 +5440,7 @@ namespace jdi
continue;
}
const bool highlighted = (m_cursorHover && m_hoverCursor == which);
const std::uint32_t color = CursorColor(which);
const std::uint32_t color = CursorColor();
UiFillRoundRect(g, labelRect, 3.0f * m_scale,
highlighted ? color : WithAlpha(color, 0xE0));
const bool dark = IsDarkColor(color);
@@ -5526,7 +5459,7 @@ namespace jdi
if (spanRect.Width > 0.0f && spanRect.Height > 0.0f)
{
// 样式与光标时间读数完全一致(同底色/同描边/同文字配色)。
const std::uint32_t color = CursorColor(1);
const std::uint32_t color = CursorColor();
UiFillRoundRect(g, spanRect, 3.0f * m_scale,
m_spanHover ? color : WithAlpha(color, 0xE0));
const bool dark = IsDarkColor(color);
@@ -5628,21 +5561,6 @@ namespace jdi
return layout;
}
gd::RectF PlotView::EdgePanelRect(int laneIndex) const
{
return EdgePanelLayoutFor(laneIndex, EdgePanelKind::COUNT).panel;
}
gd::RectF PlotView::EdgePanelCloseRect(int laneIndex) const
{
return EdgePanelLayoutFor(laneIndex, EdgePanelKind::COUNT).close;
}
gd::RectF PlotView::EdgeCenterPanelRect(int laneIndex) const
{
return EdgePanelLayoutFor(laneIndex, EdgePanelKind::CENTER).panel;
}
bool PlotView::IsOnEdgeCursorLine(int x, int y, int& laneIndex) const
{
laneIndex = -1;
@@ -5934,7 +5852,7 @@ namespace jdi
std::vector<Lane>& tabLanes = m_tab->Lanes();
const std::size_t count = std::min(lanes.size(), tabLanes.size());
const std::uint32_t color = CursorColor(1);
const std::uint32_t color = CursorColor();
const bool dark = IsDarkColor(color);
// ---- 横向光标(线与两端把手 + 左侧幅值读数)----
@@ -6334,7 +6252,7 @@ namespace jdi
? std::wstring(L"松开左键放回本网格")
: (L"移动到网格 " + std::to_wstring(target + 1) +
L":松开左键确认");
const float textWidth = UiTextWidth(g, hint, m_fonts->uiSmall) + 16.0f * m_scale;
const float textWidth = UiMeasureTextWidth(m_fonts->uiSmall, hint) + 16.0f * m_scale;
const float height = 20.0f * m_scale;
float left = targetRect.X + (targetRect.Width - textWidth) * 0.5f;
left = std::max(m_plotRect.X, std::min(left, m_plotRect.X + m_plotRect.Width - textWidth));
@@ -6373,7 +6291,7 @@ namespace jdi
const std::wstring text = resolved.data->Title() + L" · 按住拖拽可移入其它网格";
// 提示跟随鼠标:在可拖拽区域内持续移动时,提示条也要跟着走。
const float textWidth = UiTextWidth(g, text, m_fonts->uiSmall) + 16.0f * m_scale;
const float textWidth = UiMeasureTextWidth(m_fonts->uiSmall, text) + 16.0f * m_scale;
const float height = 20.0f * m_scale;
float left = static_cast<float>(m_mouseX) + 12.0f * m_scale;
if (left + textWidth > m_plotRect.X + m_plotRect.Width)