修复色域拖拽回弹、网格 GX 拖拽重排、均值滤波多阶与逐信号条目
1. 自定义颜色面板:拖动时鼠标移出控件不再"弹回去"
- 根因是选点位置每帧都从 RGB 反推:色相 1 与 0 是同一个颜色(红),拖到色相条底部
下一帧反推回 0,指示条弹到顶部;拖到色域方块右下角之外时明度为 0(黑色),
黑色的饱和度无定义,反推得 0,选点弹到最左边。
- 现在把"选点位置(饱和度/明度)与色相"作为独立状态保存,只由对应控件与外部改色维护;
越界一律夹取到最近边界,因此鼠标离开控件后选点停在边界上。
- 统一色域方块、色相条、预览色块与色号框的圆角;RGB 滑块适当加粗;
色域选点去掉外圈深色描边(只保留白色描边),色相指示器改为白色描边的圆角长方条、
底色取该位置的颜色;色相条改用分段线性渐变绘制。
2. 网格 GX 编号支持拖拽重排
- 按住网格图例左侧的 GX 徽标即可上下拖动,整块网格(连同波形与标尺)跟随鼠标移动;
途经的网格保持自身大小、整体让出一格,目标槽位有吸附高亮提示。
- 松开后真正重排并从下到上/从上到下重新编号,信号列表徽标、图例徽标、菜单与浮动面板
中所有 GX 编号同步更新;手动排布后切换为自定义划分,后续重建网格不会打乱次序。
- 拖动期间复用静态场景缓存,按网格条带平移贴图,因此大文件下依然流畅。
3. 均值滤波升级为"均值点数 X + 阶数 N"
- 原"均值点数 N"更名"均值点数 X",新增"阶数 N":预览曲线以 X 点均值滤波的结果为蓝本,
再重复同样的滤波共 N 阶(1 阶即与原来的单次滤波逐位一致)。
- 浮动面板改为逐信号条目:第一排是信号名与复选框,第二排是均值点数与阶数输入;
只有勾选的信号才绘制预览曲线,未勾选时不显示第二排;启用功能时默认只勾选第一个信号。
- 参数按信号保存(同一网格内不同信号可用不同参数),「构建为新信号」按各自参数构建。
This commit is contained in:
1 parent
2d029fb09b
commit
bc8db72f18
8 files changed
+1138
-181
No files matched your search
+129
-4
@@ -127,7 +127,7 @@ namespace jdi
|
||||
double edgeCenterPanelX = -1.0;
|
||||
double edgeCenterPanelY = -1.0;
|
||||
bool meanFilter = false;
|
||||
int meanFilterRadius = 5;
|
||||
std::vector<Lane::MeanFilterItem> meanFilterItems;
|
||||
bool meanFilterPanelOpen = true;
|
||||
double meanFilterPanelX = -1.0;
|
||||
double meanFilterPanelY = -1.0;
|
||||
@@ -152,7 +152,7 @@ namespace jdi
|
||||
carry.edgeCenterPanelX = lane.edgeCenterPanelX;
|
||||
carry.edgeCenterPanelY = lane.edgeCenterPanelY;
|
||||
carry.meanFilter = lane.meanFilter;
|
||||
carry.meanFilterRadius = lane.meanFilterRadius;
|
||||
carry.meanFilterItems = lane.meanFilterItems;
|
||||
carry.meanFilterPanelOpen = lane.meanFilterPanelOpen;
|
||||
carry.meanFilterPanelX = lane.meanFilterPanelX;
|
||||
carry.meanFilterPanelY = lane.meanFilterPanelY;
|
||||
@@ -188,7 +188,7 @@ namespace jdi
|
||||
lane.edgeCenterPanelX = carry.edgeCenterPanelX;
|
||||
lane.edgeCenterPanelY = carry.edgeCenterPanelY;
|
||||
lane.meanFilter = carry.meanFilter;
|
||||
lane.meanFilterRadius = carry.meanFilterRadius;
|
||||
lane.meanFilterItems = carry.meanFilterItems;
|
||||
lane.meanFilterPanelOpen = carry.meanFilterPanelOpen;
|
||||
lane.meanFilterPanelX = carry.meanFilterPanelX;
|
||||
lane.meanFilterPanelY = carry.meanFilterPanelY;
|
||||
@@ -969,6 +969,67 @@ namespace jdi
|
||||
}
|
||||
}
|
||||
|
||||
void ComputeMovingAverageIterated(const std::vector<double>& values, int radius, int order,
|
||||
std::vector<float>& out)
|
||||
{
|
||||
const int stages = std::max(1, order);
|
||||
// 第 1 阶:从原始采样值出发。
|
||||
ComputeMovingAverage(values, radius, out);
|
||||
if (stages == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 后续各阶以上一阶的结果为输入(double 中转,避免 float→double 的精度损失累积)。
|
||||
std::vector<double> buffer(values.size(), std::numeric_limits<double>::quiet_NaN());
|
||||
std::vector<float> stage;
|
||||
for (int iteration = 1; iteration < stages; ++iteration)
|
||||
{
|
||||
for (std::size_t index = 0; index < out.size(); ++index)
|
||||
{
|
||||
buffer[index] = std::isfinite(out[index]) ? static_cast<double>(out[index])
|
||||
: std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
ComputeMovingAverage(buffer, radius, stage);
|
||||
out.swap(stage);
|
||||
}
|
||||
}
|
||||
|
||||
const Lane::MeanFilterItem* Lane::FindMeanFilterItem(const SignalRef& ref) const
|
||||
{
|
||||
for (const MeanFilterItem& item : meanFilterItems)
|
||||
{
|
||||
if (item.ref == ref)
|
||||
{
|
||||
return &item;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Lane::MeanFilterItem& Lane::EnsureMeanFilterItem(const SignalRef& ref)
|
||||
{
|
||||
for (MeanFilterItem& item : meanFilterItems)
|
||||
{
|
||||
if (item.ref == ref)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
MeanFilterItem item;
|
||||
item.ref = ref;
|
||||
meanFilterItems.push_back(item);
|
||||
return meanFilterItems.back();
|
||||
}
|
||||
|
||||
void Lane::RemoveMeanFilterItem(const SignalRef& ref)
|
||||
{
|
||||
meanFilterItems.erase(
|
||||
std::remove_if(meanFilterItems.begin(), meanFilterItems.end(),
|
||||
[&ref](const MeanFilterItem& item) { return item.ref == ref; }),
|
||||
meanFilterItems.end());
|
||||
}
|
||||
|
||||
int FindNearestSample(const DataFile& file, double time)
|
||||
{
|
||||
const std::size_t count = file.time.size();
|
||||
@@ -1192,6 +1253,23 @@ namespace jdi
|
||||
--ref.signalIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// 均值滤波条目同样持有信号引用,必须一起删除/前移。
|
||||
std::vector<Lane::MeanFilterItem>& items = lane.meanFilterItems;
|
||||
items.erase(std::remove_if(items.begin(), items.end(),
|
||||
[fileIndex, signalIndex](const Lane::MeanFilterItem& item)
|
||||
{
|
||||
return item.ref.fileIndex == fileIndex &&
|
||||
item.ref.signalIndex == signalIndex;
|
||||
}),
|
||||
items.end());
|
||||
for (Lane::MeanFilterItem& item : items)
|
||||
{
|
||||
if (item.ref.fileIndex == fileIndex && item.ref.signalIndex > signalIndex)
|
||||
{
|
||||
--item.ref.signalIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 被移除信号若独占了某个网格,该网格随之消失(与取消勾选的行为一致)。
|
||||
m_lanes.erase(std::remove_if(m_lanes.begin(), m_lanes.end(),
|
||||
@@ -1485,7 +1563,15 @@ namespace jdi
|
||||
lane.edgeCenterPanelX = source.edgeCenterPanelX;
|
||||
lane.edgeCenterPanelY = source.edgeCenterPanelY;
|
||||
lane.meanFilter = source.meanFilter;
|
||||
lane.meanFilterRadius = source.meanFilterRadius;
|
||||
// 拆分后每个子网格只保留自己那个信号的均值滤波条目。
|
||||
lane.meanFilterItems.clear();
|
||||
for (const Lane::MeanFilterItem& item : source.meanFilterItems)
|
||||
{
|
||||
if (item.ref == ref)
|
||||
{
|
||||
lane.meanFilterItems.push_back(item);
|
||||
}
|
||||
}
|
||||
lane.meanFilterPanelOpen = source.meanFilterPanelOpen;
|
||||
lane.meanFilterPanelX = source.meanFilterPanelX;
|
||||
lane.meanFilterPanelY = source.meanFilterPanelY;
|
||||
@@ -1529,6 +1615,14 @@ namespace jdi
|
||||
++ref.signalIndex;
|
||||
}
|
||||
}
|
||||
// 均值滤波条目同样持有信号引用,必须一起后移。
|
||||
for (Lane::MeanFilterItem& item : lane.meanFilterItems)
|
||||
{
|
||||
if (item.ref.fileIndex == fileIndex && item.ref.signalIndex >= insertPos)
|
||||
{
|
||||
++item.ref.signalIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1560,6 +1654,37 @@ namespace jdi
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TabConfig::MoveLane(int from, int target)
|
||||
{
|
||||
const int count = static_cast<int>(m_lanes.size());
|
||||
if (from < 0 || from >= count || target < 0 || target > count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// `target` 语义 = 「插入到该下标之前」;向后拖时扣除自身占位后再比较,
|
||||
// 保证"拖到自己原来的位置"不会产生无意义的移动。
|
||||
int destination = target;
|
||||
if (destination > from)
|
||||
{
|
||||
--destination;
|
||||
}
|
||||
destination = std::max(0, std::min(destination, count - 1));
|
||||
if (destination == from)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Lane moved = std::move(m_lanes[static_cast<std::size_t>(from)]);
|
||||
m_lanes.erase(m_lanes.begin() + from);
|
||||
m_lanes.insert(m_lanes.begin() + destination, std::move(moved));
|
||||
|
||||
// 手动排布 → 切换到自定义划分策略,避免后续重建网格时顺序被还原。
|
||||
m_laneMode = LaneMode::CUSTOM;
|
||||
RenameLanes();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TabConfig::RenameLanes()
|
||||
{
|
||||
for (std::size_t index = 0; index < m_lanes.size(); ++index)
|
||||
|
||||
Reference in new issue
Block a user