fix: 修正样式区对齐与线宽输入交互,分组标题改为“组X|文件名”并支持同文件重复加载
样式编辑区: - 标签列与内容列改为靠左对齐(原为整体居中),拉宽左侧面板时不再向中间偏移。 - 颜色行不再居中,与样式、透明度、线宽三行共用同一左边界与同一宽度上限 (260 逻辑像素),实测四行均为 89-413px,右侧留 93px 空白。 线宽输入: - 双击数值框后数值整体居中并高亮(外框与数值呈选中态),首次键入即整体覆盖原值, 之后显示插入符;回车确认、Esc 取消、点击其它区域确认,交互与常见登录输入框一致。 散点绘制: - 散点半径改为随线宽线性增长(0.5-10px 映射到 1.6-12px,系数 1.5), 修复此前半径被上限 4px 过早截断、线宽较大时数据点不再放大的问题。 透明度描边: - 新增统一色块绘制入口 UiDrawSwatch:按不透明度填充,且仅在不透明度低于 45% 时 补一圈描边;可见时不绘制描边。 - 预设色块、自定义色块、信号行色块与波形图例色块统一走该入口, 修复透明度过低时完全不可见的问题。 文件分组: - 分组标题改为“组X|<文件名>”,序号使用强调色;序号按当前位置连续编号, 关闭某个分组后其余分组自动重新编号。 - 移除按路径查重的限制,同一文件可多次加载并分别归入不同分组。 - 关闭分组改为“移至末位后弹出 + 收缩容量”,使该文件的时间轴与全部信号缓冲区 在本次调用内立即析构归还系统。 - 确认加载后不再依赖原始文件:读取阶段即关闭句柄并整份载入内存, 已实测删除源文件后仍可正常勾选与绘制波形。 验证:make clean && make all(Release+Debug)零错误零警告; 逐项以真实/合成鼠标与像素扫描核对以上行为。
This commit is contained in:
1 parent
dbe9b904ab
commit
cba62c8218
7 files changed
+134
-82
No files matched your search
@@ -121,7 +121,7 @@ namespace jdi
|
||||
bool AddFromTable(const CsvTable& table, const std::wstring& filePath, std::wstring& error, int& fileIndex);
|
||||
|
||||
/**
|
||||
* @brief 移除指定下标的文件。
|
||||
* @brief 移除指定下标的文件,并立即释放其占用的全部采样内存。
|
||||
* @param [IN] fileIndex 文件下标。
|
||||
* @return 移除成功返回 true。
|
||||
*/
|
||||
@@ -165,13 +165,6 @@ namespace jdi
|
||||
*/
|
||||
const SignalData* Resolve(const SignalRef& ref) const;
|
||||
|
||||
/**
|
||||
* @brief 按路径查找已加载文件下标。
|
||||
* @param [IN] filePath 文件完整路径。
|
||||
* @return 文件下标,未找到返回 -1。
|
||||
*/
|
||||
int IndexOfFile(const std::wstring& filePath) const;
|
||||
|
||||
/**
|
||||
* @brief 计算全部文件时间范围的并集下限。
|
||||
* @return 时间下限。
|
||||
|
||||
@@ -232,6 +232,26 @@ namespace jdi
|
||||
*/
|
||||
void UiDrawCheckBox(gd::Graphics& g, const gd::RectF& rect, int state, float radius);
|
||||
|
||||
/**
|
||||
* @brief 绘制颜色样块:叠加不透明度填充,透明度过低时补充描边以保证可辨识。
|
||||
* @param [IN,OUT] g 绘图上下文。
|
||||
* @param [IN] rect 样块矩形。
|
||||
* @param [IN] color 基础颜色(0xAARRGGBB,其 Alpha 通道会被不透明度覆盖)。
|
||||
* @param [IN] opacity 不透明度(0-1)。
|
||||
* @param [IN] radius 圆角半径。
|
||||
* @param [IN] scale DPI 缩放比例,用于推导描边粗细。
|
||||
* @return 实际填充颜色的 0xAARRGGBB 值(供需要同步其他元素的调用方使用)。
|
||||
*/
|
||||
std::uint32_t UiDrawSwatch(gd::Graphics& g, const gd::RectF& rect, std::uint32_t color, float opacity,
|
||||
float radius, float scale);
|
||||
|
||||
/**
|
||||
* @brief 判断给定不透明度是否低到需要为样块补充描边。
|
||||
* @param [IN] opacity 不透明度(0-1)。
|
||||
* @return 需要描边返回 true。
|
||||
*/
|
||||
bool UiSwatchNeedsOutline(float opacity);
|
||||
|
||||
} // namespace jdi
|
||||
|
||||
#endif // __PAINT_UTIL_HPP__
|
||||
+10
-13
@@ -414,7 +414,16 @@ namespace jdi
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_files.erase(m_files.begin() + fileIndex);
|
||||
|
||||
// 用移动到末位后弹出的方式移除,使被移除文件的时间轴与全部信号缓冲区在本调用内
|
||||
// 立即析构归还操作系统,不再等待后续插入覆盖;最后收缩容量,避免残留空闲块。
|
||||
const std::size_t position = static_cast<std::size_t>(fileIndex);
|
||||
for (std::size_t index = position; index + 1 < m_files.size(); ++index)
|
||||
{
|
||||
m_files[index] = std::move(m_files[index + 1]);
|
||||
}
|
||||
m_files.pop_back();
|
||||
m_files.shrink_to_fit();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -451,18 +460,6 @@ namespace jdi
|
||||
return &file->signals[static_cast<std::size_t>(ref.signalIndex)];
|
||||
}
|
||||
|
||||
int DataSet::IndexOfFile(const std::wstring& filePath) const
|
||||
{
|
||||
for (std::size_t index = 0; index < m_files.size(); ++index)
|
||||
{
|
||||
if (m_files[index].filePath == filePath)
|
||||
{
|
||||
return static_cast<int>(index);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
double DataSet::MinTime() const
|
||||
{
|
||||
double value = std::numeric_limits<double>::infinity();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "PaintUtil.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
namespace jdi
|
||||
@@ -7,6 +8,14 @@ namespace jdi
|
||||
|
||||
namespace
|
||||
{
|
||||
/**
|
||||
* @brief 颜色样块补充描边的不透明度阈值。
|
||||
*
|
||||
* 不透明度低于该值时,色块自身与浅色背景的对比度已不足,需要额外描边才能辨识;
|
||||
* 高于该值时按需求不绘制描边,保持与预设色块一致的纯净外观。
|
||||
*/
|
||||
const float kSwatchOutlineOpacity = 0.45f;
|
||||
|
||||
/**
|
||||
* @brief 构造圆角矩形路径。
|
||||
* @param [IN,OUT] path 目标路径对象。
|
||||
@@ -420,4 +429,37 @@ namespace jdi
|
||||
}
|
||||
}
|
||||
|
||||
bool UiSwatchNeedsOutline(float opacity)
|
||||
{
|
||||
return !(opacity >= kSwatchOutlineOpacity);
|
||||
}
|
||||
|
||||
std::uint32_t UiDrawSwatch(gd::Graphics& g, const gd::RectF& rect, std::uint32_t color, float opacity,
|
||||
float radius, float scale)
|
||||
{
|
||||
double alpha = static_cast<double>(opacity);
|
||||
if (!(alpha > 0.0))
|
||||
{
|
||||
alpha = 0.0;
|
||||
}
|
||||
if (alpha > 1.0)
|
||||
{
|
||||
alpha = 1.0;
|
||||
}
|
||||
|
||||
const std::uint32_t filled = WithAlpha(color, static_cast<unsigned int>(alpha * 255.0 + 0.5));
|
||||
if (rect.Width > 0.0f && rect.Height > 0.0f)
|
||||
{
|
||||
UiFillRoundRect(g, rect, radius, filled);
|
||||
|
||||
// 透明度过低时色块本身难以辨识,补充一圈描边以保持可读性;可见时不绘制描边。
|
||||
if (UiSwatchNeedsOutline(opacity))
|
||||
{
|
||||
UiDrawRoundRect(g, rect, radius, SolarizedLight().borderStrong,
|
||||
std::max(1.0f, scale));
|
||||
}
|
||||
}
|
||||
return filled;
|
||||
}
|
||||
|
||||
} // namespace jdi
|
||||
Reference in new issue
Block a user