File indexing completed on 2024-12-22 03:35:46

0001 /*
0002     File                 : MatioFilter.h
0003     Project              : LabPlot
0004     Description          : Matio I/O-filter
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2021 Stefan Gerlach <stefan.gerlach@uni.kn>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #ifndef MATIOFILTER_H
0010 #define MATIOFILTER_H
0011 
0012 #include "backend/datasources/filters/AbstractFileFilter.h"
0013 
0014 class MatioFilterPrivate;
0015 
0016 // Docu:
0017 //      matio_user_guide.pdf
0018 //      http://na-wiki.csc.kth.se/mediawiki/index.php/MatIO
0019 //      https://github.com/NJannasch/matio-examples
0020 // Example data:
0021 //      https://github.com/cran/R.matlab/tree/master/inst/mat-files
0022 //      https://github.com/scipy/scipy/tree/master/scipy/io/matlab/tests/data/
0023 class MatioFilter : public AbstractFileFilter {
0024     Q_OBJECT
0025 
0026 public:
0027     MatioFilter();
0028     ~MatioFilter() override;
0029 
0030     static QString fileInfoString(const QString&);
0031 
0032     void parse(const QString& fileName);
0033     void
0034     readDataFromFile(const QString& fileName, AbstractDataSource* = nullptr, AbstractFileFilter::ImportMode = AbstractFileFilter::ImportMode::Replace) override;
0035     QVector<QStringList> readCurrentVar(const QString& fileName,
0036                                         AbstractDataSource* = nullptr,
0037                                         AbstractFileFilter::ImportMode = AbstractFileFilter::ImportMode::Replace,
0038                                         int lines = -1);
0039     void write(const QString& fileName, AbstractDataSource*) override;
0040 
0041     void setCurrentVarName(const QString&);
0042     void setSelectedVarNames(const QStringList&);
0043     const QStringList selectedVarNames() const;
0044     size_t varCount() const;
0045     QVector<QStringList> varsInfo() const;
0046 
0047     // TODO: -> AbstractFileFilter?
0048     void setStartRow(int);
0049     int startRow() const;
0050     void setEndRow(int);
0051     int endRow() const;
0052     void setStartColumn(int);
0053     int startColumn() const;
0054     void setEndColumn(int);
0055     int endColumn() const;
0056 
0057     void save(QXmlStreamWriter*) const override;
0058     bool load(XmlStreamReader*) override;
0059 
0060 private:
0061     std::unique_ptr<MatioFilterPrivate> const d;
0062 
0063     friend class MatioFilterPrivate;
0064 };
0065 
0066 #endif