QWT API (中文) 7.3.0
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#ifndef QWT_DEBUG_DRAW
57#define QWT_DEBUG_DRAW 0
58#endif
59
60#ifndef QWT_DEBUG_PRINT
61#define QWT_DEBUG_PRINT 0
62#endif
101#ifndef QWT_DECLARE_PRIVATE
102#define QWT_DECLARE_PRIVATE(classname) \
103 class PrivateData; \
104 friend class classname::PrivateData; \
105 std::unique_ptr< PrivateData > m_data; \
106 inline PrivateData* d_func() \
107 { \
108 return (m_data.get()); \
109 } \
110 inline const PrivateData* d_func() const \
111 { \
112 return (m_data.get()); \
113 }
114#endif
115
122#ifndef QWT_DECLARE_PUBLIC
123#define QWT_DECLARE_PUBLIC(classname) \
124 friend class classname; \
125 classname* q_ptr { nullptr }; \
126 inline classname* q_func() \
127 { \
128 return (static_cast< classname* >(q_ptr)); \
129 } \
130 inline const classname* q_func() const \
131 { \
132 return (static_cast< const classname* >(q_ptr)); \
133 }
134#endif
135
141#ifndef QWT_PIMPL_CONSTRUCT
142#define QWT_PIMPL_CONSTRUCT m_data(qwt_make_unique< PrivateData >(this))
143#endif
144
150#ifndef QWT_PIMPL_CONSTRUCT_INIT
151#define QWT_PIMPL_CONSTRUCT_INIT() \
152 do { \
153 m_data = qwt_make_unique< PrivateData >(this); \
154 } while (0)
155#endif
156
161#ifndef QWT_D
162#define QWT_D(pointerName) PrivateData* pointerName = d_func()
163#endif
164
169#ifndef QWT_DC
170#define QWT_DC(pointerName) const PrivateData* pointerName = d_func()
171#endif
172
177#ifndef QWT_Q
178#define QWT_Q(classname, pointerName) classname* pointerName = q_func()
179#endif
180
185#ifndef QWT_QC
186#define QWT_QC(classname, pointerName) const classname* pointerName = q_func()
187#endif
188
189#if __cplusplus >= 201402L
190// C++14 or later, use standard library make_unique
191template< typename T, typename... Args >
192std::unique_ptr< T > qwt_make_unique(Args&&... args)
193{
194 return std::make_unique< T >(std::forward< Args >(args)...);
195}
196
197template< typename T >
198std::unique_ptr< T > qwt_make_unique(std::size_t size)
199{
200 return std::make_unique< T >(size);
201}
202
203#else
204// C++11 custom implementation
205
206// Basic version - normal object
207template< typename T, typename... Args >
208std::unique_ptr< T > qwt_make_unique(Args&&... args)
209{
210 return std::unique_ptr< T >(new T(std::forward< Args >(args)...));
211}
212
213// Array specialization version - dynamic array
214template< typename T >
215std::unique_ptr< T > qwt_make_unique(std::size_t size)
216{
217 return std::unique_ptr< T >(new typename std::remove_extent< T >::type[ size ]());
218}
219
220#endif
221
222#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
223#ifndef qwt_as_const
224#define qwt_as_const std::as_const
225#endif
226#else
227// C++14 and below use Qt's qwt_as_const
228#ifndef qwt_as_const
229#define qwt_as_const qAsConst
230#endif
231#endif
232
233#endif