feat/dataset-detail-chart #5
|
|
@ -30,9 +30,15 @@ void ColorBarWidget::paintEvent(QPaintEvent* /*event*/) {
|
||||||
|
|
||||||
const int barY = 2;
|
const int barY = 2;
|
||||||
const int barH = kBarHeight;
|
const int barH = kBarHeight;
|
||||||
|
// 居中约 74% 宽(对齐原版:色阶条不占满,两侧各留 ~13% 边距)。
|
||||||
|
const int marginX = static_cast<int>(W * 0.13);
|
||||||
|
const int barLeft = marginX;
|
||||||
|
const int barRight = W - marginX;
|
||||||
|
const int barW = barRight - barLeft;
|
||||||
|
if (barW < 10) return;
|
||||||
// 等宽色带:每相邻断点一格,等宽(对齐原版图例,非按值比例)。
|
// 等宽色带:每相邻断点一格,等宽(对齐原版图例,非按值比例)。
|
||||||
const int nSeg = static_cast<int>(stops.size()) - 1;
|
const int nSeg = static_cast<int>(stops.size()) - 1;
|
||||||
auto segX = [&](int i) { return static_cast<int>(static_cast<double>(i) / nSeg * (W - 1)); };
|
auto segX = [&](int i) { return barLeft + static_cast<int>(static_cast<double>(i) / nSeg * barW); };
|
||||||
|
|
||||||
for (int i = 0; i < nSeg; ++i) {
|
for (int i = 0; i < nSeg; ++i) {
|
||||||
int xL = segX(i), xR = segX(i + 1);
|
int xL = segX(i), xR = segX(i + 1);
|
||||||
|
|
@ -42,7 +48,7 @@ void ColorBarWidget::paintEvent(QPaintEvent* /*event*/) {
|
||||||
}
|
}
|
||||||
// 外边框
|
// 外边框
|
||||||
p.setPen(QPen(QColor(120, 120, 120), 1));
|
p.setPen(QPen(QColor(120, 120, 120), 1));
|
||||||
p.drawRect(0, barY, W - 1, barH - 1);
|
p.drawRect(barLeft, barY, barW - 1, barH - 1);
|
||||||
|
|
||||||
// 边界值标签(深色文字,白底可见),在各分格边界下方。
|
// 边界值标签(深色文字,白底可见),在各分格边界下方。
|
||||||
QFont font = p.font();
|
QFont font = p.font();
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,12 @@ RawDataChartView::RawDataChartView(QWidget* parent) : QWidget(parent) {
|
||||||
auto* panner = new QwtPlotPanner(plot_->canvas());
|
auto* panner = new QwtPlotPanner(plot_->canvas());
|
||||||
panner->setMouseButton(Qt::LeftButton);
|
panner->setMouseButton(Qt::LeftButton);
|
||||||
|
|
||||||
new QwtPlotMagnifier(plot_->canvas());
|
auto* magnifier = new QwtPlotMagnifier(plot_->canvas());
|
||||||
|
// 反转滚轮方向:Qwt 默认 wheelFactor=0.9 → 上滚缩小;取倒数使「上滚=放大」(常规习惯)。
|
||||||
|
magnifier->setWheelFactor(1.0 / 0.9);
|
||||||
|
|
||||||
|
// 允许随停靠面板自由收缩(不强制最小宽度→不出横向滚动条,对齐原版响应式填充)。
|
||||||
|
plot_->setMinimumSize(0, 0);
|
||||||
lay->addWidget(plot_, 1);
|
lay->addWidget(plot_, 1);
|
||||||
|
|
||||||
// ---- 独立色阶条(固定高 36px,QwtPlot 的兄弟 widget)----
|
// ---- 独立色阶条(固定高 36px,QwtPlot 的兄弟 widget)----
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue