github czyt1988/QWT v7.6.0
QwtPlot v7.6.0

latest release: v7.6.1
3 days ago

New Features

  • Automatic plot area (axis) alignment for the retained grid of QwtFigure
    • The members of a grid column now share the left/right canvas edges and the members of a row share the top/bottom ones, so their axis backbones, tick marks, grid lines and data areas line up even when the tick labels, titles, legends or parasite axes of the members have very different sizes. A member spanning several tracks joins the groups of the first and of the last track it covers; the alignment follows added/removed members, ratio changes and axis range changes and is switched with QwtFigure::setGridAxisAlignment() (isGridAxisAlignment(), on by default)
    • The alignment is based on the real plot area, not on the extent of a single scale: a plot area alignment pass measures the natural "canvas inset" of every participant (tick labels, axis titles, legends, color bars and the whole axis stack of parasite plots included), raises it to the largest inset of the group and applies the result as a minimum canvas inset of QwtPlotLayout (new setMinCanvasInset(), minCanvasInset(), resetMinCanvasInsets()) with the natural canvas rect exposed as naturalCanvasRect(). The natural layout stays authoritative, so aligning never clips labels and works for hidden axes as well
    • QwtFigure::addAxisAlignment()/alignAxes() were reimplemented on top of this mechanism: a manual group names the edge to align (QwtAxis::YLeft/YRight/XBottom/XTop), overlapping groups of one side are merged transitively, removeAxisAlignment()/clearAxisAlignment() restore the natural plot areas of the affected plots, and duplicate configurations are ignored. The alignment is recomputed from the figure layout, from replotAll(), before saveFig() and from the layout requests of the members, so it stays correct without manual calls
    • Regression tests: tests/figure_axis_align_test covers the column/row groups, spanning members, manual groups and their connected components, member removal/re-adding, disableGrid(), parasite axes, axis range changes, hidden members and the QwtPlotLayout inset primitive
  • Retained grid layout and draggable dividers in QwtFigure
    • QwtFigureGrid is a retained grid model: it owns the row/column track ratios, the gap (setSpacing()) and the (row, column, rowSpan, columnSpan) registration of its members, and computes the normalized cell rectangles on demand, so the proportions survive resizes; wspace()/hspace() return the retained gaps, so the host can persist what setSpacing() stored
    • QwtFigure::enableGrid() creates/enables the model, addAxes(plot, row, col, rowSpan, colSpan) and addGridItem(widget, ...) register members, removeWidget() unregisters them, and the existing normalized-coordinate members keep working next to grid members
    • QwtFigureGridSplitter makes the dividers draggable: QwtFigure::setGridEditable(true) installs it, and it only consumes the mouse events inside a ± 4 pixel band around a divider (setHitWidth()) instead of covering the figure with an overlay, so zooming, panning, picking and hovering keep working. The cursor switches to SplitHCursor/SplitVCursor and is applied to the widget under the mouse (typically the canvas), so it stays visible even when the canvas has a cursor of its own; a drag changes only the two adjacent tracks, clamped by minimumTrackPixels() (40 pixels by default), the member repaints are suspended while dragging, and Esc cancels the drag and restores the ratios. The drag grabs the mouse on the figure, so the release always returns to the splitter even when a filter installed on a canvas afterwards consumes the move/release events; a lost grab (UngrabMouse) or a deactivated window ends the drag the same way
    • gridSizesChanged() reports the intermediate ratios, gridSizesChangeFinished() is emitted exactly once on release and only when the ratios really changed, so the DA layer can push one undo command per drag. 3D (QOpenGLWidget) members are never intercepted: the boundary of a 3D cell is served by the adjacent 2D plot
    • A mouse press on a sub plot - delivered to its canvas - makes it the current axes (currentAxesChanged()), without consuming the event. Qt invokes event filters in reverse installation order (the last installed runs first): install the host's own canvas filters before setGridEditable(true), or call setGridEditable(true) once more afterwards - enabling an already enabled splitter re-scans and re-installs its filters ahead of the host filters
    • tests/figure_grid_test, tests/figure_grid_layout_test and tests/figure_grid_splitter_test cover the track math, the layout integration and the interaction (hit band, column-only drag, minimum track clamp, finished signal count, Esc, disabled repaints, pass-through outside the band, canvas-delivered activation, split cursor on the canvas, lost-release fallbacks)
  • QwtFigure::disableGrid() leaves the grid without moving the members
    • Leaving the retained grid turns every grid member into a free member whose normalized rectangle is taken from the geometry the layout actually assigned to it, so the sub plots keep their position and size and nothing jumps. A member that is hidden at that moment is converted from its grid cell instead, because its last pixel geometry may predate a resize of the figure; free members that were never part of the grid are untouched, so a figure mixing both kinds ends up with free members only
    • The track ratios and the spacing are dropped and the divider interaction is switched off, so leaving the grid is not reversible: enableGrid() needs the row/column counts again and setGridEditable(true) has to be called once more. A figure without a grid reports false and is left unchanged. Regression tests: tests/figure_grid_layout_test (testDisableGridKeepsGeometry, testDisableGridMixedMembers, testDisableGridIdempotent) and tests/figure_grid_test (testDisableGrid)
  • examples/2D/figure: draggable grid demo
    • A new "Grid layout (draggable)" toolbar action switches the demo to a 2x2 retained grid (waveform spanning the top row, two analysis plots below) with editable dividers; switching back rebuilds the classic demo. The sub plot overlay is disabled while the grid is editable so it does not swallow the divider events
  • examples/2D/figureGrid: retained grid layout example
    • A dedicated 3 x 3 demo that exercises the whole model: six members (four single cell plots, one plot spanning two columns, one plain widget registered with addGridItem()), track ratio presets, live wspace/hspace and minimumTrackPixels controls, configurable divider hit width, one undo command per drag built from gridSizesChangeFinished() (undo/redo actions and shortcuts), runtime removal and re-adding of a member, and leaving the grid with disableGrid() and re-entering it. The splitter is found with findChild<>(), so the example shows how to reach setHitWidth() and hoverChanged() without adding to the public QwtFigure API
    • The members are aligned automatically and the "Plot area alignment" group of the dock switches setGridAxisAlignment() at runtime. The data of the demo is chosen so the effect is visible: the spectrogram uses Hz tick labels, the trend plot carries a left legend, the bar chart a percentage axis on the right and the scatter plot a two line title, so every column/row would otherwise start its plot area at a different position
    • Implements the unattended screenshot protocol with the drag (two synthetic divider drags through the splitter), spacing and noalign (alignment switched off) variants; docs/assets/screenshots/figure-grid{,-drag,-spacing,-noalign}.png are generated from it
  • Flat SVG icon set for the example toolbars
    • examples/common/icons collects 24 x 24 stroked line art in a two color palette (neutral gray plus an accent blue, matching the icons of the parasitePlot example) and an icons.qrc that every example compiles in; the design rules, the file naming and the usage are documented in examples/common/icons/README.md
    • Every 2D example toolbar uses the shared icons now (export, print, zoom, save, screenshot, clear, help, grid/rotate/mirror, spline overlay/closed, figure layout and undo/redo); toolbars that only had text buttons show icon plus label with a 20 px icon size, and the outdated XPM bitmaps of bode, polardemo and realtime are removed with their Pixmaps.h/*.xpm files
    • The 3D example toolbars keep icon only buttons - the bars are crowded by combos already - and use the action text as tooltip; the animation and run toggles swap between the play and pause icon with their checked state. figureGrid and downsample_demo also got the target level AUTORCC property the other iconified targets already had

Breaking Changes

  • 3D grid data is indexed as data[row][column]
    • Qwt3DSurface::loadFromData(), Qwt3DBar::setSamples() and every other grid entry point used z[column][row] (first index = x), a legacy of QwtPlot3D: callers that hold a row-major matrix (DataFrame, NumPy, MATLAB, matplotlib's plot_surface) had to transpose it first, and passing such a matrix untransposed read out of bounds whenever the column count differed from the row count, which crashed the caller
    • Every entry point uses the matrix layout now: Qwt3DSurface::loadFromData() (double** and Triple**), Qwt3DBar::setSamples() (double** and Qwt3DFunctionData), Qwt3DFunctionData::z, Qwt3DParametricData::vertices, Qwt3DGridData (rows() is the outer dimension and columns() the inner one, vertices and normals are [row][column]), the row-major matrices Qwt3DFunction::create()/Qwt3DParametricSurface::create() emit, Qwt3DNativeReader and the surface geometry indices (row * columns + column)
    • Normals and the periodic sewing compute the same physical values as before - only the storage indexing changed - so code that transposed for the old convention passes its matrix as is now. The examples, the tests (deliberately non-square now), the bench harnesses and the 3D use guide are updated

Bug Fixes

  • The former QwtFigure alignment kernel (unifying the scale minimum extent, the edge margin and the border distances) is replaced by the plot area alignment above: it overwrote the edge margins that QwtPlot::updateAxisEdgeMargin() maintains for parasite axis stacks, could not align differences caused by legends, color bars or hidden axes, could not shrink an inset again when a member left a group (the plots kept the old minimum extent) and depended on the axis being visible. removeAxisAlignment()/clearAxisAlignment() now restore the natural plot areas, and the alignment survives a figure resize, a member change and a new axis range
  • Retained grid hardening
    • QwtFigureGrid::setSpacing() rejects a gap with (trackCount - 1) * gap >= 1 (warning, previous values kept, the request is rejected as a whole) instead of letting the last track collapse to a zero extent; dividers() clamps a divider position into [0, 1], so the hit band of the splitter cannot leave the figure
    • QwtFigureLayout rounds both edges of a cell from the accumulated normalized position and derives the pixel extent from them, so the right edge of a cell and the left edge of its neighbour are the same pixel instead of leaving a one pixel seam (same rule on the Y axis)
    • Dragging a divider no longer runs the whole figure layout twice per mouse move: the splitter relies on the synchronous layout pass that QwtFigure already drives from QwtFigureGrid::sizesChanged()
    • Regression tests: tests/figure_grid_test (testSpacingGetters, testSpacingUpperBoundRejected, testDividersWithinUnitRange), tests/figure_grid_layout_test (testCumulativeEdgeRounding), tests/figure_grid_splitter_test (testDragRelayoutsImmediately)
  • Fixed the right axis backbone flickering between its pen width and twice that width while resizing the window at fractional display scaling ( 125 %, 150 %, 175 % ), f.e. 2 and 4 device pixels at a pen width of 2: the backing store of QwtPlotCanvas was qRound( size * ratio ) device pixels and was drawn at the logical origin, but Qt rounds both edges of the paint region independently, so the device footprint of the canvas depends on its position and can be one column/row larger than the pixmap. The canvas is opaque, so nothing painted the uncovered column - it kept stale window content, typically the backbone of the right axis from before the resize, which sits right beside the canvas and doubled its visible width. The backing store is now sized to the device footprint of the canvas and blitted 1:1 in device coordinates whenever the painter maps by a pure uniform scale; other transformations keep the previous path. Integer scaling is unaffected
  • Regression test: tests/axis_corner_test gained testCanvasCoversDeviceFootprint(), which renders the canvas at eight subpixel offsets and checks that every device pixel of the footprint is painted and none beyond it; CTest runs the suite at a device pixel ratio of 1.75 as well
  • Fixed a transparent strip at the right and bottom edge of the canvas backing store at fractional display scaling when the background is painted by a style sheet ( styled background ) or by a rounded border: the pixmap is sized to the device footprint of the canvas and can exceed the logical canvas rect by a fraction of a device pixel, but the styled background covers the logical rect only. The strip stayed transparent and the blit blended it with stale window content - typically the backbone of the right axis from before a resize, which made the axis look up to two device pixels wider and left a stray vertical line when the right axis was disabled. The remainder of the pixmap is now filled with the canvas background
  • Regression test: tests/axis_corner_test gained testStyledCanvasCoversDeviceFootprint(), the styled background variant of the footprint test above
  • Fixed the OpenGL canvas being scaled and cropped on mixed DPI desktops: QwtPlotOpenGLCanvas::paintGL() sized its FBO with QwtPainter::devicePixelRatio( nullptr ), which falls back to the maximum device pixel ratio over all screens instead of the ratio of the screen the canvas is on. On a 100 % + 150 % desktop a canvas on the 100 % screen rendered into a 1.5x FBO, and the 1:1 blit into the QOpenGLWidget framebuffer showed only the top left part of the plot, scaled up by 1.5; the canvas now uses devicePixelRatioF(). Uniform DPI setups are unaffected
  • QwtPlotOpenGLCanvas now uses the same default frame width as QwtPlotCanvas ( 0, no visible border ): init() forced a one pixel QFrame::Box, adding an inner border the raster canvas never had
  • Fixed the OpenGL canvas backing store not covering its whole device footprint at fractional display scaling: the FBO is round( size * ratio ) device pixels, but the canvas background covers the logical rect only, so the last column/row kept uninitialized content. On Qt 6.12 - whose compositor repeats the last texture column when the widget footprint is one device pixel narrower - that column showed as a 1-2 pixel bar at the right edge that came and went while resizing. The remainder is filled with the canvas background now, like the QwtPlotCanvas backing store
  • Fixed the 3D label text looking doubled: every label was painted twice into a pixmap, once into a one bit QBitmap installed as mask and once as the colored text, and the monochrome mask of an antialiased glyph rasterizes differently, so every stem showed a one pixel shifted duplicate ( reported for Chinese titles, tic numbers and axis titles alike ). The text is painted once into a transparent image now and the text shader samples its alpha channel, so the glyphs keep their antialiasing and no mask exists. The label quad was also placed at fractional device pixel positions, which let the bilinear filter spread every glyph edge over two pixels - a second source of the doubled look; convert2screen() snaps the quad to the device pixel grid and draw() rebuilds its corners from the snapped rectangle, so the quad always covers exactly width() x height() device pixels. Descenders are no longer clipped ( the pixmap height took r.bottom() instead of r.height() )
  • Fixed the arrow keys cancelling the QwtFigureWidgetOverlay: Qt::Key_Right/Key_Down fell through into the Qt::Key_Escape case, so navigating with the arrow keys also called cancel() and hid the overlay. Found by the GCC -Wall -Wextra pass below
  • Fixed the three warnings the 3D sources trigger in a Qt 6.12 MinGW Release build: QImage::mirrored() is deprecated since Qt 6.9 (flipped(Qt::Vertical) on Qt >= 6.9, mirrored() before, flipped() does not exist earlier), operator*(const QMatrix4x4&, const QVector3D&) is deprecated since Qt 6.1 (QMatrix4x4::map() is available in Qt 5 as well), and the Qwt3DCellData/Qwt3DGridData destructors called the virtual clear() (clang-analyzer-optin.cplusplus.VirtualCall): CellData only owns vectors, so its destructor is defaulted, and GridData releases its raw arrays through the new non virtual releaseData(), which setSize() - called from the constructor - uses as well

Performance

  • Unchanged 3D labels are no longer re-rasterized
    • Qwt3DAxis::drawTicLabel() reapplied font, color and text of every tic label on every frame and Qwt3DLabel::draw() created and uploaded a texture per label per frame, so a plot with 3 x 21 tic labels spent most of its frame time on text that had not changed at all. setFont()/setString()/setColor() are no-ops for an unchanged value now, so m_flagForUpdate is only set by real changes, and the text texture is cached in the label: it is rebuilt only when the text image, the GL context or the screen DPI changed. The DPI the text was rasterized for is remembered and compared in draw(), because the offscreen pixmap resolves a point sized font against the primary screen; the GL name is dropped whenever its context is not current. Measured on a 900 x 700 plot with VSync off and repaint per frame: 21 tic labels per axis 23.6 ms -> 8.4 ms, 2 labels per axis 8.1 ms -> 4.2 ms, output pixel identical
  • All 3D labels are drawn with a single atlas draw call
    • Every label still uploaded its own quad and issued its own draw call, so the frame time of a text heavy plot was dominated by per label GL overhead ( a 900 x 700 scene with 3 x 101 tic labels needed 70 ms per frame ). The new Qwt3DTextBatch packs the label images into one atlas texture and collects the screen aligned quads while the drawables are traversed; Qwt3DPlot flushes the batch with a single draw call at the end of each draw phase ( scene and fixed overlay ), and the per label texture path stays as fallback for images that do not fit into the atlas. The atlas is shelf packed, keeps a per label stamp so unchanged labels are not composited again, and grows with a re-pack on the next frame; the text shader takes a per vertex color instead of the uTextColor uniform, so labels with different colors share one call, and Qwt3DRenderContext carries the batch. The vector export skips the flush ( GL_FEEDBACK plus shader draws is undefined, gl2ps emits the text itself ). Measured: 303 labels 70.1 ms -> 2.6 ms, 63 labels 21.3 ms -> 2.2 ms, 6 labels 7.7 ms -> 2.1 ms. The output differs in 14 pixels, because text is now drawn above the axis lines it overlaps ( the batch flushes after the coordinate system ), and the vector export no longer contains the NaN polygons the per label textured quads produced

Build

  • examples/bench/chartbench fetches its optional QIm submodule during configure when qim/ is empty: the pinned submodule commit is checked out, a shallow clone is the fallback for release archives without a .git directory, and a failed download (no network, no git) only disables the QIm adapter instead of failing the configure step. The attempt is non-interactive, time limited and remembered per build tree; CHARTBENCH_QIM_AUTOFETCH, CHARTBENCH_QIM_DIR, CHARTBENCH_QIM_URL, CHARTBENCH_QIM_FETCH_TIMEOUT and CHARTBENCH_QIM_FETCH_ATTEMPTED control it
  • Fixed the Qt 5 / MinGW build, which two C++14 constructs had broken under CMAKE_CXX_STANDARD 11: QwtRoundF has a default member initializer, which keeps it from being an aggregate in C++11, so it got an explicit constructor instead of the braced initialization list, and qwt3d_plot.cpp used std::make_unique - qwt_make_unique is the project's C++11 fallback. The unused w/h arguments of Qwt3DPlot::renderPixmap() are marked as such, which -Wall reports once it is enabled
  • Fixed the 28 warnings a GCC 7.3 build with -Wall -Wextra reported, all of them except the two in the bundled gl2ps code: besides the overlay arrow key bug above, qwt3d_coordsys.cpp could read left uninitialized ( the grid line color is baked into the vertex buffer already, the unused locals and the unused lineColor argument are removed ), qwt3d_autoscaler.cpp carried an unused floor125() that also wrote past the end of its two element vector, and the static qwtStepSize() of the date scale engine was renamed to qwtDateStepSize() - inside the amalgamated single translation unit it shared a TU with QwtScaleArithmetic::qwtStepSize() and the call resolved to the wrong overload. The rest are unused variables/functions, member initialization order and Q_UNUSED for intentionally unused arguments
  • src-amalgamate/QwtPlot.{h,cpp} were regenerated for the new QwtPlotLayout minimum canvas inset API, the reworked QwtFigure axis alignment, QwtFigure::disableGrid(), the 3D label batching and the 3D grid indexing change; compile-verified as a single translation unit with /bigobj

Documentation

  • Figure widget use guide (EN/CN): the "Retained Grid Layout" section was rewritten - what the model is for and when to use it, the role split between QwtFigure, QwtFigureGrid, QwtFigureGridSplitter and QwtFigureLayout (with a class diagram), the full model API including the normalization and spacing validation rules, the divider interaction, an undo recipe, leaving the grid with disableGrid(), and the new example with three screenshots. The feature is also listed in the 7.x new features page, plot-layout.md and the showcase galleries
    • The "Axis Alignment" section of the figure widget guide (EN/CN) documents the new mechanism (real plot area edges instead of scale extents, legends/parasites/hidden axes covered, the automatic grid alignment and its switch, connected manual groups, the lifecycle hooks) and shows the aligned vs. unaligned figureGrid screenshots
  • Example toolbar audit (examples/TOOLBAR-ICONS.md): which example programs have a toolbar, which buttons it contains and which icon each button uses, plus a pointer to the icon set design rules and how the documentation screenshots are regenerated. The screenshots of the iconified toolbars were refreshed ( 30 images under docs/assets/screenshots )
  • 3D use guide (EN/CN): the grid data indexing is documented as data[row][column] ( row = y direction, column = x direction ) at every loadFromData()/setSamples() entry point, matching the matrix layout of the 3D surface pipeline tech report
中文说明(点击展开)

新功能

  • QwtFigure 保留式网格的自动绘图区(坐标轴)对齐
    • 网格同一列的成员共享画布的左右边缘,同一行的成员共享上下边缘,因此即使各成员的刻度标签、轴标题、图例或寄生坐标轴尺寸差异很大,坐标轴轴线、刻度、网格线和数据区也会落在同一条线上;跨多个轨道的成员参与其首、末轨道的分组。对齐会跟随成员的增删、轨道比例变化和坐标轴范围变化自动更新,可用 QwtFigure::setGridAxisAlignment() 开关(isGridAxisAlignment() 查询,默认开启)
    • 对齐基于真实的绘图区边缘,而不是单一坐标轴的刻度 extent:对齐通道测量每个参与者自身的「画布内缩」(包含刻度标签、轴标题、图例、颜色条以及寄生绘图的整条轴带),取组内最大值,再通过 QwtPlotLayout 新增的 setMinCanvasInset()/minCanvasInset()/resetMinCanvasInsets() 作为最小内缩应用,自然画布矩形由 naturalCanvasRect() 暴露。自然布局始终优先,因此对齐不会挤压成员真正需要的空间,也不会裁剪标签,隐藏的坐标轴同样参与对齐
    • QwtFigure::addAxisAlignment()/alignAxes() 改为基于该机制实现:手动分组指定要对齐的边(QwtAxis::YLeft/YRight/XBottom/XTop),同一侧重叠的分组按传递闭包合并,removeAxisAlignment()/clearAxisAlignment() 会把相关绘图恢复到自然布局,重复添加相同分组会被忽略。对齐由 figure 布局、replotAll()、saveFig() 以及成员的布局请求自动触发,一般无需手动调用
    • 回归测试:tests/figure_axis_align_test 覆盖列/行分组、跨轨道成员、手动分组及其传递闭包、成员移除与重新添加、disableGrid()、寄生坐标轴、坐标轴范围变化、隐藏成员以及 QwtPlotLayout 的内缩原语
  • QwtFigure 支持保留式网格布局与可拖拽分隔条
    • QwtFigureGrid 是保留式网格模型:保存行/列轨道比例、间距(setSpacing())以及成员的 (行, 列, 行跨度, 列跨度) 登记,按需计算归一化单元格矩形,窗口缩放后比例保持不变;wspace()/hspace() 返回保留的间距,宿主可据此持久化 setSpacing() 写入的值
    • QwtFigure::enableGrid() 创建并启用模型,addAxes(plot, row, col, rowSpan, colSpan) 与 addGridItem() 登记成员,removeWidget() 取消登记;原有的归一化坐标成员可与网格成员共存
    • QwtFigureGridSplitter 让分隔条可拖拽:QwtFigure::setGridEditable(true) 启用,它只拦截分隔条 ±4 像素窄带内的事件(setHitWidth() 可调),不使用覆盖整窗的蒙版,因此缩放、平移、拾取、悬停不受影响;光标切换为 SplitHCursor/SplitVCursor 并设置在鼠标实际所在的控件上(通常是画布),画布自身带有显式光标时也能正确显示;拖动只改变相邻两条轨道比例并受 minimumTrackPixels()(默认 40 像素)约束,拖动中暂停成员重绘,Esc 取消并恢复原比例。拖动期间 figure 抓取鼠标,松手事件总会回到分隔条——即使宿主之后在 canvas 上安装的过滤器消费了 move/release;鼠标抓取丢失(UngrabMouse)或窗口失活时按同样方式取消
    • gridSizesChanged() 汇报拖动中的比例;gridSizesChangeFinished() 只在松手且比例确实变化时发出一次,DA 层可据此为整次拖动压入一条撤销命令。3D(QOpenGLWidget)成员不会被拦截:3D 单元格的边界由相邻的 2D 绘图一侧负责命中
    • 在子绘图上按下鼠标(真实点击投递给其 canvas)即把它设为当前激活子图(currentAxesChanged()),且不消费事件。Qt 事件过滤器按安装的相反顺序调用(后装先调):宿主自己的 canvas 过滤器应在 setGridEditable(true) 之前安装,或之后再次调用 setGridEditable(true)——对已启用的分隔条再次启用会重扫并重装其过滤器,排在宿主过滤器之前
    • tests/figure_grid_test、tests/figure_grid_layout_test、tests/figure_grid_splitter_test 覆盖轨道数学、布局集成与交互行为(命中带、只改目标方向、最小轨道 clamp、完成信号次数、Esc、重绘开关、带外放行、canvas 投递激活、画布光标、松手丢失兜底)
  • QwtFigure::disableGrid() 退出网格并保持成员的当前几何
    • 退出保留式网格会把每个网格成员转成自由成员,其归一化矩形取自布局实际分配给它的几何,因此子绘图保持当前的位置和大小,不会跳动。当时处于隐藏状态的成员改为按其网格单元换算,因为它最后的像素几何可能早于窗口缩放;从未属于网格的自由成员不受影响,混合两类成员的 figure 退出后只剩自由成员
    • 轨道比例与间距会被丢弃、分隔条交互会关闭,因此退出网格不可逆:再次调用 enableGrid() 需要重新给出行列数,setGridEditable(true) 也要重新调用一次。没有网格的 figure 返回 false 且不做任何改动。回归测试:tests/figure_grid_layout_test(testDisableGridKeepsGeometry、testDisableGridMixedMembers、testDisableGridIdempotent)与 tests/figure_grid_test(testDisableGrid)
  • examples/2D/figure:可拖拽网格演示
    • 工具栏新增「Grid layout (draggable)」动作,切换到 2x2 保留式网格(波形占顶行,下方两个分析图)并可拖动分隔条;切回时重建经典演示。网格可编辑期间禁用子图蒙版,避免它吞掉分隔条事件
  • examples/2D/figureGrid:保留式网格布局示例
    • 专门的 3×3 演示,覆盖了模型的大部分能力:六个成员(四个单格绘图、一个跨两列的绘图、一个用 addGridItem() 登记的普通控件)、比例预设、wspace/hspace 与 minimumTrackPixels 实时控制、可调的分隔条命中宽度、由 gridSizesChangeFinished() 驱动的「一次拖动一条撤销命令」(撤销/重做动作与快捷键)、运行时移除并重新添加成员、用 disableGrid() 退出网格并重新进入。例子用 findChild<>() 取得分隔条,演示了不扩展 QwtFigure 公开接口也能调用 setHitWidth() 和 hoverChanged()
    • 成员默认自动对齐,dock 里的「Plot area alignment」分组可在运行时切换 setGridAxisAlignment()。示例数据刻意让效果可见:频谱图使用 Hz 刻度标签、趋势图带左图例、柱状图带右侧百分比坐标轴、散点图使用两行标题,不开启对齐时各成员绘图区的起点会明显不同
    • 支持无界面截图协议,drag(两次经分隔条的合成拖动)、spacing 与 noalign(关闭对齐)三个变体用于生成 docs/assets/screenshots/figure-grid{,-drag,-spacing,-noalign}.png
  • 示例工具栏统一改用扁平 SVG 图标
    • examples/common/icons 收录 24×24 描边线条图标,配色为两色(中性灰加强调蓝,与 parasitePlot 示例原有的图标一致),并提供可编入每个示例的 icons.qrc;设计规则、文件命名与用法记录在 examples/common/icons/README.md
    • 所有 2D 示例工具栏改用这套共享图标(导出、打印、缩放、保存、截图、清空、帮助、网格/旋转/镜像、样条叠加/闭合、figure 布局以及撤销/重做);原先只有文字按钮的工具栏改为图标加文字(图标 20 像素),bode、polardemo、realtime 三个示例过时的 XPM 位图连同 Pixmaps.h/*.xpm 一并移除
    • 3D 示例工具栏保留纯图标按钮(工具栏已被下拉框占满),动作文字用作 tooltip;动画与运行开关按选中状态在播放/暂停图标之间切换。figureGrid 与 downsample_demo 也补上了其他图标化目标已有的 target 级 AUTORCC 属性

破坏性变更

  • 3D 网格数据改为 data[row][column] 索引
    • Qwt3DSurface::loadFromData()、Qwt3DBar::setSamples() 以及其他所有网格入口此前使用 z[column][row](第一个下标是 x),这是 QwtPlot3D 的历史约定:持有行主序矩阵(DataFrame、NumPy、MATLAB、matplotlib 的 plot_surface)的调用者必须先转置,而未转置直接传入时只要列数与行数不等就会越界读取,导致调用方崩溃
    • 现在所有入口统一使用矩阵布局:Qwt3DSurface::loadFromData()(double** 与 Triple**)、Qwt3DBar::setSamples()(double** 与 Qwt3DFunctionData)、Qwt3DFunctionData::z、Qwt3DParametricData::vertices、Qwt3DGridData(rows() 为外层维度、columns() 为内层维度,顶点与法线均为 [row][column])、Qwt3DFunction::create()/Qwt3DParametricSurface::create() 输出的行主序矩阵、Qwt3DNativeReader 以及曲面几何索引(row * columns + column)
    • 法线与周期缝合计算的物理量与此前一致——只有存储下标改变——因此为旧约定做过转置的代码现在直接传入矩阵即可。示例、测试(现在刻意使用非方阵)、基准程序与 3D 使用指南均已更新

Bug 修复

  • 旧的 QwtFigure 对齐内核(统一刻度 minimumExtent、edgeMargin 与 borderDist)被上述绘图区对齐取代:它会覆盖 QwtPlot::updateAxisEdgeMargin() 为寄生坐标轴维护的 edgeMargin;无法对齐由图例、颜色条或隐藏坐标轴造成的差异;成员离开分组后无法把内缩收缩回去(仍保留旧的最小 extent);而且要求坐标轴可见。现在 removeAxisAlignment()/clearAxisAlignment() 会恢复自然绘图区,对齐在窗口缩放、成员变化和坐标轴范围变化后都能保持
  • 保留式网格加固
    • QwtFigureGrid::setSpacing() 现在拒绝 (轨道数 - 1) * gap >= 1 的间距(qWarning、保持原值、整条请求一起拒绝),不再让最后一个轨道被压成零尺寸;dividers() 把分隔条位置 clamp 到 [0, 1],分隔条命中带不会跑到图外
    • QwtFigureLayout 改为对累计归一化位置的两个边分别取整,再由两条边求像素宽度,相邻单元的右边缘与下一单元左边缘落在同一像素,不再出现 1 像素缝(Y 方向同一规则)
    • 拖动分隔条时不再每次鼠标移动都整图布局两遍:分隔条直接依赖 QwtFigure 由 QwtFigureGrid::sizesChanged() 驱动的同步布局通道
    • 回归测试:tests/figure_grid_test(testSpacingGetters、testSpacingUpperBoundRejected、testDividersWithinUnitRange)、tests/figure_grid_layout_test(testCumulativeEdgeRounding)、tests/figure_grid_splitter_test(testDragRelayoutsImmediately)
  • 修复非整数显示缩放(125%、150%、175%)下调整窗口宽度时,右侧轴线宽度在笔宽与两倍笔宽之间跳变的问题(例如笔宽 2 时在 2 与 4 个设备像素之间变化):QwtPlotCanvas 的 backing store 尺寸为 qRound( size * ratio ) 个设备像素,并在逻辑原点绘制;而 Qt 对绘制区域的两条边分别取整,画布覆盖的设备像素数取决于其位置,可能比 pixmap 多出一列/一行。画布是不透明的,没有任何绘制会覆盖这一列,它保留的是窗口的旧内容——通常就是缩放前紧贴画布的右侧轴线,于是轴线看起来变宽一倍。现在只要 painter 的设备变换是纯粹的等比缩放,backing store 就按画布实际覆盖的设备像素区域分配,并在设备坐标下 1:1 贴图;其他变换保持原有路径。整数缩放不受影响
  • 回归测试:tests/axis_corner_test 新增 testCanvasCoversDeviceFootprint(),在 8 个亚像素偏移下渲染画布,检查覆盖区域内每个设备像素都被绘制、区域外不被绘制;CTest 额外以设备像素比 1.75 运行该套件
  • 修复非整数显示缩放下、画布背景由样式表或圆角边框绘制时,backing store 右侧和底部边界出现透明条带的问题:pixmap 按画布的设备足迹分配,可能比控件逻辑矩形宽出不到一个设备像素,而样式表背景只覆盖逻辑矩形。该条带保持透明,1:1 贴图时按混合模式与窗口旧内容叠加——通常正是缩放前紧贴画布的右侧轴线,导致轴线看起来最多变宽两个设备像素,关闭右轴时则留下一条时隐时现的竖线。现在 pixmap 逻辑矩形之外的剩余列/行会用画布背景填充
  • 回归测试:tests/axis_corner_test 新增 testStyledCanvasCoversDeviceFootprint(),即上述足迹测试的样式表背景版本
  • 修复混合 DPI 桌面上 OpenGL 画布被放大并裁切的问题:QwtPlotOpenGLCanvas::paintGL() 用 QwtPainter::devicePixelRatio( nullptr ) 决定 FBO 尺寸,而该函数返回所有屏幕中最大的设备像素比,不是画布所在屏幕的像素比。在 100% + 150% 的桌面上,位于 100% 屏幕的画布会按 1.5 倍创建 FBO,1:1 blit 到 QOpenGLWidget 帧缓冲后只剩绘图区左上部分并按 1.5 倍放大;现在改用画布的 devicePixelRatioF()。统一 DPI 的环境不受影响
  • QwtPlotOpenGLCanvas 现在与 QwtPlotCanvas 使用相同的默认边框宽度(0,无可见边框):init() 强制了 1 像素的 QFrame::Box,给 GL 画布增加了一圈光栅画布没有的内边框
  • 修复非整数显示缩放下 OpenGL 画布 backing store 没有覆盖完整设备足迹的问题:FBO 为 round( size * ratio ) 个设备像素,而画布背景只覆盖逻辑矩形,最后一列/行保留未初始化内容。Qt 6.12 的合成器在控件设备足迹比纹理窄 1 个设备像素时会重复纹理最后一列,于是该列表现为右侧时隐时现的 1-2 像素竖条。现在剩余列/行会用画布背景填充,与 QwtPlotCanvas 的 backing store 一致
  • 修复 3D 标签文字出现重影的问题:每个标签此前会把文字在 pixmap 上绘制两遍,一遍画进作为 mask 的 1 位 QBitmap,一遍画彩色文字,而抗锯齿字形的单色 mask 栅格化结果与之不匹配,于是每个笔画都出现一个偏移 1 像素的重影(中文标题、刻度数字与轴标题都会出现)。现在改为把文字绘制一次到透明图像,由文字着色器采样其 alpha 通道,字形保留抗锯齿且不再需要 mask。标签四边形此前还落在非整数设备像素位置,双线性过滤会把每条字形边扩散到两个像素——这是重影的第二个来源;convert2screen() 现在把四边形吸附到设备像素网格,draw() 由吸附后的矩形重建四个角点,四边形始终正好覆盖 width() × height() 个设备像素。字母的下伸部分也不再被裁掉(此前 pixmap 高度取的是 r.bottom() 而不是 r.height())
  • 修复 QwtFigureWidgetOverlay 的方向键会取消遮罩的问题:Qt::Key_Right/Key_Down 落进了 Qt::Key_Escape 分支,用方向键移动选择时同时调用了 cancel() 并隐藏了遮罩。该缺陷由下面的 GCC -Wall -Wextra 检查发现
  • 修复 3D 源码在 Qt 6.12 MinGW Release 构建中的三个警告:QImage::mirrored() 自 Qt 6.9 起废弃(Qt >= 6.9 用 flipped(Qt::Vertical),更早版本仍用 mirrored(),因为 flipped() 在 6.9 之前不存在);operator*(const QMatrix4x4&, const QVector3D&) 自 Qt 6.1 起废弃(QMatrix4x4::map() 在 Qt 5 同样可用);Qwt3DCellData/Qwt3DGridData 的析构函数调用了虚函数 clear()(clang-analyzer-optin.cplusplus.VirtualCall):CellData 只持有 vector,析构函数直接默认实现,GridData 改由新增的非虚 releaseData() 释放裸数组,构造函数中调用的 setSize() 也走这条路径

性能优化

  • 未变化的 3D 标签不再重复栅格化
    • Qwt3DAxis::drawTicLabel() 每帧都会重新设置每个刻度标签的字体、颜色与文本,Qwt3DLabel::draw() 每帧为每个标签创建并上传一次纹理,因此 3×21 个刻度标签的绘图大部分帧时间都花在完全没有变化的文字上。现在值未改变时 setFont()/setString()/setColor() 直接返回,m_flagForUpdate 只由真正的改动置位;文字纹理缓存在标签内,仅在文字图像、GL 上下文或屏幕 DPI 变化时重建。光栅化所用的 DPI 被记录并在 draw() 中比较,因为离屏 pixmap 会按主屏解析点值字体;GL 名字在其上下文不是当前上下文时丢弃。在 900×700 绘图、关闭 VSync 逐帧重绘下实测:每轴 21 个刻度标签 23.6 ms -> 8.4 ms,每轴 2 个 8.1 ms -> 4.2 ms,渲染结果逐像素一致
  • 所有 3D 标签合并为一次图集绘制调用
    • 每个标签此前仍要上传自己的四边形并发起自己的绘制调用,文字密集的绘图帧时间被逐标签的 GL 开销主导(900×700、每轴 101 个刻度标签的场景每帧 70 ms)。新增的 Qwt3DTextBatch 把标签图像打包进一张图集纹理,并在遍历 drawable 时收集屏幕对齐的四边形;Qwt3DPlot 在每个绘制阶段(场景与固定叠加层)末尾以一次绘制调用刷出批次,放不进图集的图像仍走逐标签纹理路径。图集按货架算法打包,保留每个标签的图章以免重复合成未变化的标签,装满后扩容并在下一帧重新打包;文字着色器改用逐顶点颜色取代 uTextColor uniform,颜色不同的标签也能共用一次调用,批次由 Qwt3DRenderContext 携带。矢量导出跳过刷出(GL_FEEDBACK 与着色器绘制混用属未定义行为,文字由 gl2ps 自行输出)。实测:303 个标签 70.1 ms -> 2.6 ms,63 个 21.3 ms -> 2.2 ms,6 个 7.7 ms -> 2.1 ms。输出仅在 14 个像素上不同——文字现在绘制在其重叠的轴线之上(批次在坐标系之后刷出)——矢量导出也不再包含逐标签纹理四边形产生的 NaN 多边形

构建

  • examples/bench/chartbench 在 qim/ 为空时于 configure 阶段自动拉取可选的 QIm 子模块:优先检出子模块固定的提交,发布包没有 .git 目录时退回浅克隆;下载失败(无网络、未安装 git)只会禁用 QIm 适配器,不会让 configure 失败。拉取过程不交互、带超时,且每个构建目录只尝试一次;可用 CHARTBENCH_QIM_AUTOFETCH、CHARTBENCH_QIM_DIR、CHARTBENCH_QIM_URL、CHARTBENCH_QIM_FETCH_TIMEOUT、CHARTBENCH_QIM_FETCH_ATTEMPTED 控制
  • 修复 Qt 5 / MinGW 构建:两个 C++14 构造在 CMAKE_CXX_STANDARD 11 下编译失败。QwtRoundF 带有默认成员初始化器,在 C++11 中不再是聚合类型,改为显式构造函数而不是花括号初始化列表;qwt3d_plot.cpp 使用了 std::make_unique,改用项目的 C++11 回退 qwt_make_unique。Qwt3DPlot::renderPixmap() 未使用的 w/h 参数加了标记,开启 -Wall 后会报告这两个参数
  • 修复 GCC 7.3 在 -Wall -Wextra 下报出的 28 个警告,除内置 gl2ps 代码中的两个之外全部处理:除上面提到的遮罩方向键缺陷外,qwt3d_coordsys.cpp 的 left 可能被未初始化读取(网格线颜色已烘焙进顶点缓冲,未使用的局部变量与 lineColor 参数一并移除),qwt3d_autoscaler.cpp 移除未使用且会写出两元素 vector 末尾的 floor125(),日期刻度引擎的静态函数 qwtStepSize() 改名为 qwtDateStepSize()——在合成后的单一翻译单元中它与 QwtScaleArithmetic::qwtStepSize() 同处一个 TU,调用会解析到错误的重载。其余为未使用变量/函数、成员初始化顺序,以及为刻意不用的参数加 Q_UNUSED
  • src-amalgamate/QwtPlot.{h,cpp} 已为新增的 QwtPlotLayout 最小画布内缩 API、重写的 QwtFigure 坐标轴对齐、QwtFigure::disableGrid()、3D 标签批量绘制与 3D 网格索引变更重新生成,并以 /bigobj 按单一翻译单元编译验证

文档

  • figure 使用指南(中英):「保留式网格布局」章节重写——说明该功能的作用与适用场景,QwtFigure、QwtFigureGrid、QwtFigureGridSplitter、QwtFigureLayout 的职责划分(含类图),完整的模型 API 与归一化、间隙校验规则,分隔条交互,撤销实现,用 disableGrid() 退出网格,以及新示例与三张截图。7.x 新特性页、plot-layout.md 与展示页也补充了这个功能
    • 使用指南的「坐标轴对齐」一节(中英)改为介绍新机制(基于真实绘图区边缘而非刻度 extent,覆盖图例、寄生轴和隐藏坐标轴,网格自动对齐及其开关,手动分组的传递合并,生命周期触发点),并展示关闭对齐前后的 figureGrid 截图
  • 示例工具栏梳理(examples/TOOLBAR-ICONS.md):记录哪些示例程序带工具栏、工具栏包含哪些按钮、每个按钮使用哪个图标,并指向图标集的设计规则与文档截图的重新生成方式;图标化工具栏的截图已刷新(docs/assets/screenshots 下 30 张)
  • 3D 使用指南(中英):在各 loadFromData()/setSamples() 入口说明网格数据按 data[row][column] 索引(行对应 y 方向,列对应 x 方向),与 3D 曲面管线技术报告中的矩阵布局一致

Don't miss a new QWT release

NewReleases is sending notifications on new releases.