You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
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