feat(ui): 原数据散点锁定 x:y 真实比尺(QwtPlotRescaler aspect=1, Expanding)
This commit is contained in:
parent
cf47314500
commit
525c123211
|
|
@ -13,6 +13,7 @@
|
||||||
#include <qwt_plot_panner.h>
|
#include <qwt_plot_panner.h>
|
||||||
#include <qwt_plot_magnifier.h>
|
#include <qwt_plot_magnifier.h>
|
||||||
#include <qwt_plot_marker.h>
|
#include <qwt_plot_marker.h>
|
||||||
|
#include <qwt_plot_rescaler.h>
|
||||||
|
|
||||||
namespace geopro::app {
|
namespace geopro::app {
|
||||||
|
|
||||||
|
|
@ -91,8 +92,15 @@ RawDataChartView::RawDataChartView(QWidget* parent) : QWidget(parent) {
|
||||||
// 反转滚轮方向:Qwt 默认 wheelFactor=0.9 → 上滚缩小;取倒数使「上滚=放大」(常规习惯)。
|
// 反转滚轮方向:Qwt 默认 wheelFactor=0.9 → 上滚缩小;取倒数使「上滚=放大」(常规习惯)。
|
||||||
magnifier->setWheelFactor(1.0 / 0.9);
|
magnifier->setWheelFactor(1.0 / 0.9);
|
||||||
|
|
||||||
// 允许随停靠面板自由收缩(不强制最小宽度→不出横向滚动条,对齐原版响应式填充)。
|
// 允许随停靠面板自由收缩(不强制最小宽度)。
|
||||||
plot_->setMinimumSize(0, 0);
|
plot_->setMinimumSize(0, 0);
|
||||||
|
|
||||||
|
// 锁定 x:y 真实比尺(用户选定):1 数据单位 x = 1 数据单位 y(像素)。
|
||||||
|
// 参考轴 xTop、Expanding 策略——resize/缩放时维持等比,剖面呈真实"宽扁"形状。
|
||||||
|
rescaler_ = new QwtPlotRescaler(plot_->canvas(), QwtPlot::xTop, QwtPlotRescaler::Expanding);
|
||||||
|
rescaler_->setAspectRatio(1.0);
|
||||||
|
rescaler_->setEnabled(true);
|
||||||
|
|
||||||
lay->addWidget(plot_, 1);
|
lay->addWidget(plot_, 1);
|
||||||
|
|
||||||
// ---- 独立色阶条(固定高 36px,QwtPlot 的兄弟 widget)----
|
// ---- 独立色阶条(固定高 36px,QwtPlot 的兄弟 widget)----
|
||||||
|
|
@ -134,7 +142,8 @@ void RawDataChartView::setData(
|
||||||
plot_->setAxisScale(QwtPlot::xTop, bbox.left(), bbox.right());
|
plot_->setAxisScale(QwtPlot::xTop, bbox.left(), bbox.right());
|
||||||
plot_->setAxisScale(QwtPlot::yLeft, bbox.top(), bbox.bottom());
|
plot_->setAxisScale(QwtPlot::yLeft, bbox.top(), bbox.bottom());
|
||||||
}
|
}
|
||||||
|
plot_->updateAxes();
|
||||||
|
if (rescaler_) rescaler_->rescale(); // 应用真实比尺
|
||||||
plot_->replot();
|
plot_->replot();
|
||||||
|
|
||||||
// 更新色阶条
|
// 更新色阶条
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QwtPlot;
|
class QwtPlot;
|
||||||
|
class QwtPlotRescaler;
|
||||||
|
|
||||||
namespace geopro::app {
|
namespace geopro::app {
|
||||||
|
|
||||||
|
|
@ -25,6 +26,7 @@ public:
|
||||||
private:
|
private:
|
||||||
geopro::controller::DatasetDetailController::ChartData data_;
|
geopro::controller::DatasetDetailController::ChartData data_;
|
||||||
QwtPlot* plot_;
|
QwtPlot* plot_;
|
||||||
|
QwtPlotRescaler* rescaler_ = nullptr; // 锁定 x:y 真实比尺
|
||||||
ColorBarWidget* colorBar_;
|
ColorBarWidget* colorBar_;
|
||||||
QComboBox* chartTypeCombo_;
|
QComboBox* chartTypeCombo_;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue