File indexing completed on 2024-05-12 05:43:33
0001 /* 0002 Copyright (C) 2015 Volker Krause <vkrause@kde.org> 0003 0004 This program is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program. If not, see <https://www.gnu.org/licenses/>. 0016 */ 0017 0018 #ifndef GNUPLOTTER_H 0019 #define GNUPLOTTER_H 0020 0021 #include <QSize> 0022 #include <QString> 0023 0024 #include <memory> 0025 0026 class QTemporaryDir; 0027 0028 /** Turn data into a plot using a gnuplot driver template file. */ 0029 class Gnuplotter 0030 { 0031 public: 0032 explicit Gnuplotter(); 0033 Gnuplotter(const Gnuplotter& other) = delete; 0034 Gnuplotter(Gnuplotter &&other); 0035 ~Gnuplotter(); 0036 0037 Gnuplotter& operator=(const Gnuplotter &other) = delete; 0038 Gnuplotter& operator=(Gnuplotter &&other); 0039 0040 bool isValid() const; 0041 0042 void setSize(const QSize &size); 0043 void setTemplate(const QString &templateFileName); 0044 0045 QString workingDir() const; 0046 QString imageFileName() const; 0047 0048 void plot() const; 0049 0050 static bool hasGnuplot(); 0051 0052 private: 0053 void processTemplate() const; 0054 0055 QString m_templateFileName; 0056 QSize m_outputSize = { 1024, 786 }; 0057 // QTemporaryDir is not movable :-( 0058 std::unique_ptr<QTemporaryDir> m_tempDir; 0059 }; 0060 0061 #endif // GNUPLOTTER_H