Skip to content

Commit

Permalink
Adding CLI arguments w.r.t. issue #9
Browse files Browse the repository at this point in the history
  • Loading branch information
ifilot committed Sep 13, 2024
1 parent ce9149e commit 2e8e903
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
#pragma once

#define PROGRAM_NAME "Atom Architect"
#define PROGRAM_VERSION "0.2.3"
#define PROGRAM_VERSION "0.2.4"
6 changes: 5 additions & 1 deletion src/gui/interface_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ InterfaceWindow::InterfaceWindow(MainWindow *mw)
connect(this->anaglyph_widget, SIGNAL(signal_selection_message(const QString&)), this, SLOT(update_selection_label(const QString&)));
connect(this->anaglyph_widget->get_user_action().get(), SIGNAL(signal_selection_message(const QString&)), this, SLOT(update_selection_label(const QString&)));
connect(this->anaglyph_widget->get_user_action().get(), SIGNAL(signal_message_statusbar(const QString&)), this, SLOT(propagate_message_statusbar(const QString&)));
connect(this->anaglyph_widget->get_user_action().get(), SIGNAL(signal_update_structure_info()), this->structure_info_widget, SLOT(update()));
connect(this->structure_info_widget->get_fragment_selector(), SIGNAL(signal_new_fragment(const Fragment&)), this->anaglyph_widget->get_user_action().get(), SLOT(set_fragment(const Fragment&)));

// set default fragment
Expand Down Expand Up @@ -187,6 +186,11 @@ void InterfaceWindow::set_camera_mode(QAction* action) {
* @brief Loads a default structure file.
*/
void InterfaceWindow::load_default_file() {
// do not load default file if a file is already loaded (via CLI)
if(this->structure_stack.size() != 0) {
return;
}

qDebug() << "Opening default file";
const std::string filename = "OUTCAR";
QTemporaryDir tmp_dir;
Expand Down
8 changes: 8 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ void MainWindow::set_cli_parser(const QCommandLineParser& cli_parser) {
ago_widget->set_structures(sl.load_outcar(cli_parser.value("g").toStdString()));
ago_widget->show();
}

if(!cli_parser.value("o").isEmpty()) {
QString filename = cli_parser.value("o");
qDebug() << "Received CLI '-o': " << filename;
this->interface_window->open_file(filename);
statusBar()->showMessage("Loaded " + filename + ".");
this->setWindowTitle(QFileInfo(filename).fileName() + " - " + QString(PROGRAM_NAME));
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ int main(int argc, char *argv[]) {
QCommandLineOption loadGeoOpt("g", "Load geometry analysis", "file");
parser.addOption(loadGeoOpt);

QCommandLineOption openFile("o", "Open structure file", "file");
parser.addOption(openFile);

AtomArchitectApplication app(argc, argv);
qRegisterMetaType<std::vector<uint8_t>>("stdvector_uint8_t");

Expand Down

0 comments on commit 2e8e903

Please sign in to comment.