27 #include <boost/property_tree/exceptions.hpp>
28 #include <boost/property_tree/xml_parser.hpp>
30 #include <QFileDialog>
31 #include <QFormLayout>
34 #include <QMessageBox>
35 #include <QPushButton>
36 #include <QRadioButton>
39 #include <QVBoxLayout>
50 PathPage::PathPage(std::shared_ptr<Exploration>& exploration, boost::property_tree::ptree& preferences)
51 : m_exploration(exploration), m_preferences(preferences)
54 setTitle(
"Select sim data file");
55 setSubTitle(
"Please select a sim data file to use as basis for the exploration.");
58 QHBoxLayout* layout =
new QHBoxLayout;
60 QLabel* label =
new QLabel(
"Path");
61 m_file_path =
new QLineEdit;
62 m_file_path->setReadOnly(
true);
63 QPushButton* buttonBrowse =
new QPushButton(
"Browse...");
65 layout->addWidget(label);
66 layout->addWidget(m_file_path);
67 layout->addWidget(buttonBrowse);
71 connect(buttonBrowse, SIGNAL(clicked()),
this, SLOT(BrowseFile()));
74 void PathPage::BrowseFile()
79 if (settings.contains(
"last_leaf_file"))
80 path = settings.value(
"last_leaf_file").toString();
82 path = settings.value(
"workspace").toString();
84 QString file = QFileDialog::getOpenFileName(
this,
"Browse", path);
88 if (!QFile(file).exists())
92 read_xml(file.toStdString(), m_ptree, trim_whitespace);
93 }
catch (ptree_bad_path& e) {
94 QMessageBox::critical(
this,
"Read Error",
"Error in data input file", QMessageBox::Ok);
96 }
catch (ptree_bad_data& e) {
97 QMessageBox::critical(
this,
"Read Error",
"Error in data input file.", QMessageBox::Ok);
99 }
catch (xml_parser_error& e) {
100 QMessageBox::critical(
this,
"Error",
"Not a valid data input file.", QMessageBox::Ok);
102 }
catch (std::exception& e) {
103 QMessageBox::critical(
this,
"Error",
"Could not read data input file.", QMessageBox::Ok);
106 QMessageBox::critical(
this,
"Error",
"Unknown Exception", QMessageBox::Ok);
110 m_file_path->setText(file);
111 settings.setValue(
"last_leaf_file", file);
113 emit completeChanged();
116 bool PathPage::isComplete()
const
118 return !m_ptree.empty();
121 bool PathPage::validatePage()
123 m_exploration = std::make_shared<ParameterExploration>(
"Untitled", m_ptree, m_preferences);
Interface for RangeSweep.
Namespace for SimPT parameter explorer package.
Interface for ParameterExploration.
Interface for FileExploration.