QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt3d_io.h
1#ifndef QWT3D_IO_H
2#define QWT3D_IO_H
3
4#include <vector>
5#include <algorithm>
6
7#include <qstring.h>
8#include <qstringlist.h>
9#include "qwt3d_global.h"
10
11
12
13class Qwt3DPlot;
14
22class QWT3D_EXPORT Qwt3DIO
23{
24
25public:
26 // The function type that can be processed by the define... members
27 using Function = bool (*)(Qwt3DPlot*, QString const& fname);
28
34 class Functor
35 {
36 public:
37 virtual ~Functor()
38 {
39 }
40 // Must clone the content of *this for an object of a derived class
41 virtual Functor* clone() const = 0;
42 // The workhorse of the user-defined implementation
43 virtual bool operator()(Qwt3DPlot* plot, QString const& fname) = 0;
44 };
45
46 // Define an input handler for a format with a function
47 static bool defineInputHandler(QString const& format, Function func);
48 // Define an output handler for a format with a function
49 static bool defineOutputHandler(QString const& format, Function func);
50 // Define an input handler for a format with a functor
51 static bool defineInputHandler(QString const& format, Functor const& func);
52 // Define an output handler for a format with a functor
53 static bool defineOutputHandler(QString const& format, Functor const& func);
54 // Save plot to file in specified format
55 static bool save(Qwt3DPlot*, QString const& fname, QString const& format);
56 // Load plot from file in specified format
57 static bool load(Qwt3DPlot*, QString const& fname, QString const& format);
58 // Returns list of available input formats
59 static QStringList inputFormatList();
60 // Returns list of available output formats
61 static QStringList outputFormatList();
62 // Returns output handler for a format
63 static Functor* outputHandler(QString const& format);
64 // Returns input handler for a format
65 static Functor* inputHandler(QString const& format);
66
67private:
68 Qwt3DIO()
69 {
70 }
71
72 // Lightweight Functor encapsulating a Qwt3DIO::Function
73 class Wrapper : public Functor
74 {
75 public:
76 // Performs actual input
77 Functor* clone() const override
78 {
79 return new Wrapper(*this);
80 }
81 // Creates a Wrapper object from a function pointer
82 explicit Wrapper(Function h) : hdl(h)
83 {
84 }
85 // Returns a pointer to the wrapped function
86 bool operator()(Qwt3DPlot* plot, QString const& fname) override
87 {
88 return (hdl) ? (*hdl)(plot, fname) : false;
89 }
90
91 private:
92 Function hdl;
93 };
94
95 struct Entry
96 {
97 Entry();
98 ~Entry();
99
100 Entry(Entry const& e);
101 void operator=(Entry const& e);
102
103 Entry(QString const& s, Functor const& f);
104 Entry(QString const& s, Function f);
105
106 QString fmt;
107 Functor* iofunc;
108 };
109
110 struct FormatCompare
111 {
112 explicit FormatCompare(Entry const& e);
113 bool operator()(Entry const& e);
114
115 Entry e_;
116 };
117
118 struct FormatCompare2
119 {
120 explicit FormatCompare2(QString s);
121 bool operator()(Entry const& e);
122
123 QString s_;
124 };
125
126 using Container = std::vector< Entry >;
127 using IT = Container::iterator;
128
129 static bool add_unique(Container& l, Entry const& e);
130 static IT find(Container& l, QString const& fmt);
131 static Container& rlist();
132 static Container& wlist();
133 static void setupHandler();
134};
135
139class QWT3D_EXPORT Qwt3DPixmapWriter : public Qwt3DIO::Functor
140{
141 friend class Qwt3DIO;
142 QWT_DECLARE_PRIVATE(Qwt3DPixmapWriter)
143
144public:
146 ~Qwt3DPixmapWriter() override;
147
148 // Set output quality
149 void setQuality(int val);
150
151private:
152 Qwt3DIO::Functor* clone() const override;
153 bool operator()(Qwt3DPlot* plot, QString const& fname) override;
154};
155
156
157#endif
Functor class for more flexible IO handler implementation
Definition qwt3d_io.h:35
Generic interface for standard and user written I/O handlers
Definition qwt3d_io.h:23
Provides Qt's Pixmap output facilities
Definition qwt3d_io.h:140
Pure rendering window for 3D plots
Definition qwt3d_plot.h:36