QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_global.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_GLOBAL_H
28#define QWT_GLOBAL_H
29
30#include <qglobal.h>
31#include <memory>
32#include <utility>
33#include "qwt_version_info.h"
34
35#if defined(_MSC_VER) /* MSVC Compiler */
36/* template-class specialization 'identifier' is already instantiated */
37#pragma warning(disable : 4660)
38/* inherits via dominance */
39#pragma warning(disable : 4250)
40#endif // _MSC_VER
41
42#ifdef QWT_DLL
43
44#if defined(QWT_MAKEDLL) // create a Qwt DLL library
45#define QWT_EXPORT Q_DECL_EXPORT
46#else // use a Qwt DLL library
47#define QWT_EXPORT Q_DECL_IMPORT
48#endif
49
50#endif // QWT_DLL
51
52#ifndef QWT_EXPORT
53#define QWT_EXPORT
54#endif
55
56#define QWT_CONSTEXPR constexpr
57
58#ifndef QWT_DEBUG_DRAW
59#define QWT_DEBUG_DRAW 0
60#endif
61
62#ifndef QWT_DEBUG_PRINT
63#define QWT_DEBUG_PRINT 0
64#endif
146#ifndef QWT_DECLARE_PRIVATE
147#define QWT_DECLARE_PRIVATE(classname) \
148 class PrivateData; \
149 friend class classname::PrivateData; \
150 std::unique_ptr< PrivateData > m_data; \
151 inline PrivateData* d_func() \
152 { \
153 return (m_data.get()); \
154 } \
155 inline const PrivateData* d_func() const \
156 { \
157 return (m_data.get()); \
158 }
159#endif
160
176#ifndef QWT_DECLARE_PUBLIC
177#define QWT_DECLARE_PUBLIC(classname) \
178 friend class classname; \
179 classname* q_ptr { nullptr }; \
180 inline classname* q_func() \
181 { \
182 return (static_cast< classname* >(q_ptr)); \
183 } \
184 inline const classname* q_func() const \
185 { \
186 return (static_cast< const classname* >(q_ptr)); \
187 }
188#endif
189
203#ifndef QWT_PIMPL_CONSTRUCT
204#define QWT_PIMPL_CONSTRUCT m_data(qwt_make_unique< PrivateData >(this))
205#endif
206
220#ifndef QWT_PIMPL_CONSTRUCT_INIT
221#define QWT_PIMPL_CONSTRUCT_INIT() \
222 do { \
223 m_data = qwt_make_unique< PrivateData >(this); \
224 } while (0)
225#endif
226
238#ifndef QWT_D
239#define QWT_D(pointerName) PrivateData* pointerName = d_func()
240#endif
241
253#ifndef QWT_DC
254#define QWT_DC(pointerName) const PrivateData* pointerName = d_func()
255#endif
256
268#ifndef QWT_Q
269#define QWT_Q(classname, pointerName) classname* pointerName = q_func()
270#endif
271
283#ifndef QWT_QC
284#define QWT_QC(classname, pointerName) const classname* pointerName = q_func()
285#endif
286
287#if __cplusplus >= 201402L
288// C++14 或更高版本,使用标准库的 make_unique
289template< typename T, typename... Args >
290std::unique_ptr< T > qwt_make_unique(Args&&... args)
291{
292 return std::make_unique< T >(std::forward< Args >(args)...);
293}
294
295template< typename T >
296std::unique_ptr< T > qwt_make_unique(std::size_t size)
297{
298 return std::make_unique< T >(size);
299}
300
301#else
302// C++11 自定义实现
303
304// 基础版本 - 普通对象
305template< typename T, typename... Args >
306std::unique_ptr< T > qwt_make_unique(Args&&... args)
307{
308 return std::unique_ptr< T >(new T(std::forward< Args >(args)...));
309}
310
311// 数组特化版本 - 动态数组
312template< typename T >
313std::unique_ptr< T > qwt_make_unique(std::size_t size)
314{
315 return std::unique_ptr< T >(new typename std::remove_extent< T >::type[ size ]());
316}
317
318#endif
319
320#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
321#ifndef qwt_as_const
322#define qwt_as_const std::as_const
323#endif
324#else
325// C++14 及以下版本使用 Qt 的 qwt_as_const
326#ifndef qwt_as_const
327#define qwt_as_const qAsConst
328#endif
329#endif
330
331#endif