78 lines
2.0 KiB
C
78 lines
2.0 KiB
C
|
|
#ifndef PST_DELIMITEDTEXTREADER_H
|
|||
|
|
#define PST_DELIMITEDTEXTREADER_H
|
|||
|
|
|
|||
|
|
#include <QObject>
|
|||
|
|
#include <QString>
|
|||
|
|
#include <vtkSmartPointer.h>
|
|||
|
|
#include <vector>
|
|||
|
|
#include <string>
|
|||
|
|
|
|||
|
|
class vtkTable;
|
|||
|
|
class vtkDelimitedTextReader;
|
|||
|
|
|
|||
|
|
namespace pst
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @class DelimitedTextReader
|
|||
|
|
* @brief Read txt text.
|
|||
|
|
*/
|
|||
|
|
class DelimitedTextReader : public QObject
|
|||
|
|
{
|
|||
|
|
Q_OBJECT
|
|||
|
|
public:
|
|||
|
|
explicit DelimitedTextReader(QObject* parent = nullptr);
|
|||
|
|
~DelimitedTextReader();
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
void SetFilePath(const QString& filePath);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Set/get whether to treat the first line of the file as headers.
|
|||
|
|
* The default is false (no headers).
|
|||
|
|
*/
|
|||
|
|
void SetHaveHeaders(bool haveHeaders);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Specify the character(s) that will be used to separate fields. For
|
|||
|
|
* example, set this to "," for a comma-separated value file. Set
|
|||
|
|
* it to ".:;" for a file where columns can be separated by a
|
|||
|
|
* period, colon or semicolon. The order of the characters in the
|
|||
|
|
* string does not matter. Defaults to a comma.
|
|||
|
|
*/
|
|||
|
|
void SetFieldDelimiterCharacters(const QString& flag);
|
|||
|
|
|
|||
|
|
//自动为表格数据添加表头
|
|||
|
|
//包括第一列为行号下标,第一行为标签
|
|||
|
|
void AddTableHeaderAuto(bool addHeader);
|
|||
|
|
|
|||
|
|
bool Update();
|
|||
|
|
|
|||
|
|
vtkTable* GetOutput();
|
|||
|
|
|
|||
|
|
std::vector<std::string> GetXTitles();
|
|||
|
|
std::vector<std::string> GetYTitles();
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
void AddHeaderFromOriginalTable();
|
|||
|
|
//产生可用于显示成xy轴的字符串表头
|
|||
|
|
|
|||
|
|
///@生成可用于作为x和y轴的表头,
|
|||
|
|
///即THETA和PHI哪个可以作为x轴,哪个可以作为y轴
|
|||
|
|
void GenerateXYTitle();
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
QString m_filePath;
|
|||
|
|
vtkDelimitedTextReader* m_reader;
|
|||
|
|
bool m_shouldAddHeader;
|
|||
|
|
|
|||
|
|
vtkTable* m_table;
|
|||
|
|
|
|||
|
|
std::vector<std::string> m_XTitles;
|
|||
|
|
std::vector<std::string> m_YTitles;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
} //namespace PST
|
|||
|
|
|
|||
|
|
#endif // PST_DELIMITEDTEXTREADER_H
|