BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
loaderpreviewpanel.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/dataloader/loaderpreviewpanel.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
20 #include <QColor>
21 #include <QTabWidget>
22 #include <QVBoxLayout>
23 
24 namespace gui2 {
25 
26 namespace {
27 const std::string gray{"#aab7b8"};
28 const std::string blue{"#1b4f72"};
29 
30 } // namespace
31 
33  : QWidget(parent)
34  , m_textView(new ImportTextView)
35  , m_tableWidget(new ImportTableWidget)
36  , m_tabWidget(new QTabWidget)
37 {
38  auto layout = new QVBoxLayout(this);
39  layout->setContentsMargins(0, 0, 0, 0);
40 
41  m_tabWidget->addTab(m_textView, "Text view");
42  m_tabWidget->addTab(m_tableWidget, "Table view");
43 
44  layout->addWidget(m_tabWidget);
45 }
46 
47 //! Sets raw text to the TextView.
48 
50 {
51  m_textView->clear();
52  for (size_t index = 0; index < parser->totalLineCount(); ++index) {
53  auto line_data = parser->getLine(index);
54  auto parts = parser->parseResults(index);
55  auto string_to_show = Utils::AddHtmlColorTagToParts(line_data, parts, blue, gray);
56  m_textView->appendHtml(QString::fromStdString(string_to_show));
57  }
58  m_textView->moveCursor(QTextCursor::Start);
59 
61 }
62 
63 std::vector<ColumnInfo> LoaderPreviewPanel::columnInfo() const
64 {
65  return m_tableWidget->columnInfo();
66 }
67 
69 {
70  m_textView->clear();
72 }
73 
74 } // namespace gui2
Contains table with imported data.
void setRawData(const std::vector< std::vector< std::string >> &table_data)
std::vector< ColumnInfo > columnInfo() const
Text view to show imported data.
void showData(const ParserInterface *parser)
Sets raw text to the TextView.
LoaderPreviewPanel(QWidget *parent=nullptr)
std::vector< ColumnInfo > columnInfo() const
ImportTableWidget * m_tableWidget
Interface for all classes capable of parsing ASCII data into multicolumn presentation.
virtual std::vector< std::string > parseResults(size_t index) const =0
Returns parsed text for given line index.
virtual std::string getLine(size_t index) const =0
Returns original line.
virtual std::vector< std::vector< std::string > > parsedData() const =0
Returns 2D vector representing parsed text. Skipped lines are not present.
virtual size_t totalLineCount() const =0
Returns total number of lines in raw data.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
DAREFLCORE_EXPORT std::string AddHtmlColorTagToParts(const std::string &line, const std::vector< std::string > &parts, const std::string &color_parts, const std::string &color_rest)
Returns string representing original 'line', where 'parts' are surrounded with color tag.
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
Defines class CLASS?