QWT 7.0.1
Loading...
Searching...
No Matches
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 Q_DECL_CONSTEXPR
57
58#if QT_VERSION >= 0x050000
59#define QWT_OVERRIDE Q_DECL_OVERRIDE
60#define QWT_FINAL Q_DECL_FINAL
61#endif
62
63#ifndef QWT_CONSTEXPR
64#define QWT_CONSTEXPR
65#endif
66
67#ifndef QWT_OVERRIDE
68#define QWT_OVERRIDE
69#endif
70
71#ifndef QWT_FINAL
72#define QWT_FINAL
73#endif
74
75#ifndef QWT_DEBUG_DRAW
76#define QWT_DEBUG_DRAW 1
77#endif
78
79#ifndef QWT_DEBUG_PRINT
80#define QWT_DEBUG_PRINT 1
81#endif
121#ifndef QWT_DECLARE_PRIVATE
122#define QWT_DECLARE_PRIVATE(classname) \
123 class PrivateData; \
124 friend class classname::PrivateData; \
125 std::unique_ptr< PrivateData > m_data; \
126 inline PrivateData* d_func() \
127 { \
128 return (m_data.get()); \
129 } \
130 inline const PrivateData* d_func() const \
131 { \
132 return (m_data.get()); \
133 }
134#endif
135
142#ifndef QWT_DECLARE_PUBLIC
143#define QWT_DECLARE_PUBLIC(classname) \
144 friend class classname; \
145 classname* q_ptr { nullptr }; \
146 inline classname* q_func() \
147 { \
148 return (static_cast< classname* >(q_ptr)); \
149 } \
150 inline const classname* q_func() const \
151 { \
152 return (static_cast< const classname* >(q_ptr)); \
153 }
154#endif
155
161#ifndef QWT_PIMPL_CONSTRUCT
162#define QWT_PIMPL_CONSTRUCT m_data(std::make_unique< PrivateData >(this))
163#endif
164
169#ifndef QWT_D
170#define QWT_D(pointerName) PrivateData* pointerName = d_func()
171#endif
172
177#ifndef QWT_DC
178#define QWT_DC(pointerName) const PrivateData* pointerName = d_func()
179#endif
180
185#ifndef QWT_Q
186#define QWT_Q(classname, pointerName) classname* pointerName = q_func()
187#endif
188
193#ifndef QWT_QC
194#define QWT_QC(classname, pointerName) const classname* pointerName = q_func()
195#endif
196
197#if __cplusplus >= 201402L
198// C++14 或更高版本,使用标准库的 make_unique
199template< typename T, typename... Args >
200std::unique_ptr< T > qwt_make_unique(Args&&... args)
201{
202 return std::make_unique< T >(std::forward< Args >(args)...);
203}
204
205template< typename T >
206std::unique_ptr< T > qwt_make_unique(std::size_t size)
207{
208 return std::make_unique< T >(size);
209}
210
211#else
212// C++11 自定义实现
213
214// 基础版本 - 普通对象
215template< typename T, typename... Args >
216std::unique_ptr< T > qwt_make_unique(Args&&... args)
217{
218 return std::unique_ptr< T >(new T(std::forward< Args >(args)...));
219}
220
221// 数组特化版本 - 动态数组
222template< typename T >
223std::unique_ptr< T > qwt_make_unique(std::size_t size)
224{
225 return std::unique_ptr< T >(new typename std::remove_extent< T >::type[ size ]());
226}
227
228#endif
229
230#endif