QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
qwt_plot_layout.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner -> QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 ******************************************************************************/
26
27#ifndef QWT_PLOT_LAYOUT_H
28#define QWT_PLOT_LAYOUT_H
29
30#include "qwt_global.h"
31#include "qwt_plot.h"
32#include "qwt_axis_id.h"
33#include <QSize>
35
43class QWT_EXPORT QwtPlotLayout
44{
45public:
50 enum Option
51 {
55 AlignScales = 0x01,
56
61 IgnoreScrollbars = 0x02,
62
66 IgnoreFrames = 0x04,
67
71 IgnoreLegend = 0x08,
72
76 IgnoreTitle = 0x10,
77
81 IgnoreFooter = 0x20
82 };
83
84 Q_DECLARE_FLAGS(Options, Option)
85
86 explicit QwtPlotLayout();
87 virtual ~QwtPlotLayout();
88
89 void setCanvasMargin(int margin, int axis = -1);
90 int canvasMargin(int axisId) const;
91
92 void setAlignCanvasToScales(bool);
93 void setAlignCanvasToScale(int axisId, bool);
94 bool alignCanvasToScale(int axisId) const;
95
96 // Enable fixed canvas size for an axis direction (auto-lock the current
97 // dimension on the next layout). YLeft/YRight fix width; XBottom/XTop fix height.
98 void setFixedCanvasSize(int axisPos, bool on);
99 // Check if fixed canvas size is enabled for a given axis position
100 bool isFixedCanvasSize(int axisPos) const;
101
102 // Set a manual fixed canvas size, overriding the auto-captured value.
103 // A component < 0 means "use auto-capture" for that direction.
104 void setFixedCanvasSize(const QSize& size);
105 // Get the manual fixed canvas size (-1 component = auto-capture)
106 QSize fixedCanvasSize() const;
107
108 // Clear all locked canvas sizes (captured offsets and manual override),
109 // re-capturing from the current layout on the next activate(). Does not
110 // change the enabled state of each axis direction.
111 void resetFixedCanvasSize();
112
113 void setSpacing(int);
114 int spacing() const;
115
116 void setLegendPosition(QwtPlot::LegendPosition pos, double ratio);
117 void setLegendPosition(QwtPlot::LegendPosition pos);
118 QwtPlot::LegendPosition legendPosition() const;
119
120 void setLegendRatio(double ratio);
121 double legendRatio() const;
122
123 virtual QSize minimumSizeHint(const QwtPlot*) const;
124 virtual void activate(const QwtPlot* plot, const QRectF& plotRect, Options options = Options());
125 virtual void invalidate();
126
127 QRectF titleRect() const;
128 QRectF footerRect() const;
129 QRectF legendRect() const;
130 QRectF scaleRect(QwtAxisId) const;
131
132 // Geometry of the caption strip for an outside axis title
133 // (QwtScaleWidget::TitleOutside). The strip is adjacent to the scale rect:
134 // below it for YLeft/YRight/XBottom, above it for XTop. Empty if the axis
135 // has no outside title. Caption strips of all parasite layers are placed
136 // within the bands reserved by the host plot layout.
137 QRectF scaleCaptionRect(QwtAxisId) const;
138
139 QRectF canvasRect() const;
140
141protected:
142 void setTitleRect(const QRectF&);
143 void setFooterRect(const QRectF&);
144 void setLegendRect(const QRectF&);
145 void setScaleRect(QwtAxisId, const QRectF&);
146
147 // Set the geometry of the caption strip for an outside axis title
148 void setScaleCaptionRect(QwtAxisId, const QRectF&);
149
150 // Recompute all caption rects from the current scale rects and the
151 // title state of the scale widgets. Called at the end of doActivate().
152 // Derived layouts that replace scale rects after doActivate() (like
153 // QwtParasitePlotLayout copying the host rects) must call it again.
154 void updateScaleCaptionRects(const QwtPlot* plot);
155
156 void setCanvasRect(const QRectF&);
157 QwtPlotLayoutEngine* layoutEngine();
158 void doActivate(const QwtPlot* plot, const QRectF& plotRect, Options options = Options());
159
160private:
161 QwtPlotLayout(const QwtPlotLayout&) = delete;
162 QwtPlotLayout& operator=(const QwtPlotLayout&) = delete;
163
164 // Pin the canvas rect to its locked dimension(s) after the natural layout
165 // (innerRect) has been computed. Captures the offsets on first use.
166 void applyFixedCanvas(QRectF& canvasRect, const QRectF& rect);
167
168 QWT_DECLARE_PRIVATE(QwtPlotLayout)
169};
170
171Q_DECLARE_OPERATORS_FOR_FLAGS(QwtPlotLayout::Options)
172
173#endif
Layout engine for QwtPlot components.
Definition qwt_plot_layout_engine.h:22
Layout engine for QwtPlot.
Definition qwt_plot_layout.h:44
Option
Options to configure the plot layout engine.
Definition qwt_plot_layout.h:51
A 2-D plotting widget.
Definition qwt_plot.h:100
LegendPosition
Position of the legend, relative to the canvas.
Definition qwt_plot.h:117