Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ncvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ bool wxNcVisApp::OnInit() {
// Process command line arguments
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " [options] <filename> [filename] ... " << std::endl;
std::cout << "Options:" << std::endl;
std::cout << " -var <name> Load variable on startup" << std::endl;
exit(-1);
}

Expand All @@ -60,7 +62,8 @@ bool wxNcVisApp::OnInit() {
if ((wxString("-g") == argv[iarg]) ||
(wxString("-uxc") == argv[iarg]) ||
(wxString("-uyc") == argv[iarg]) ||
(wxString("-mcr") == argv[iarg])
(wxString("-mcr") == argv[iarg]) ||
(wxString("-var") == argv[iarg])
) {
if (iarg+1 == argc) {
std::cout << "Option " << argv[iarg] << " missing required parameter" << std::endl;
Expand Down Expand Up @@ -89,6 +92,8 @@ bool wxNcVisApp::OnInit() {
if (vecFilenames.size() == 0) {
std::cout << "ERROR: No filenames specified" << std::endl;
std::cout << "Usage: " << argv[0] << " [options] <filename> [filename] ... " << std::endl;
std::cout << "Options:" << std::endl;
std::cout << " -var <name> Load variable on startup" << std::endl;
exit(-1);
}

Expand Down
36 changes: 36 additions & 0 deletions src/wxNcVisFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ wxNcVisFrame::wxNcVisFrame(
m_fRegional = true;
}

auto itVar = mapOptions.find("-var");
if (itVar != mapOptions.end()) {
m_strStartupVariable = itVar->second;
}

auto itMCS = mapOptions.find("-mcr");
if (itMCS != mapOptions.end()) {
m_dMaxCellRadius = stof(itMCS->second.ToStdString());
Expand Down Expand Up @@ -845,6 +850,37 @@ void wxNcVisFrame::InitializeWindow() {
//customvarsizer->Add(new wxTextCtrl(this, (-1), _T(""), wxDefaultPosition, wxSize(240,m_wxDataTransButton->GetSize().GetHeight()+4), wxTE_PROCESS_ENTER), 2, wxEXPAND | wxALL, 4);


if (!m_strStartupVariable.IsEmpty()) {
bool fFound = false;

for (int vc = 0; vc < NcVarMaximumDimensions; vc++) {
if (m_vecwxVarSelector[vc] == NULL) {
continue;
}

int ix = m_vecwxVarSelector[vc]->FindString(m_strStartupVariable);
if (ix != wxNOT_FOUND) {
m_vecwxVarSelector[vc]->SetSelection(ix);

wxCommandEvent evt(wxEVT_COMBOBOX, ID_VARSELECTOR + vc);
evt.SetEventObject(m_vecwxVarSelector[vc]);
evt.SetInt(ix);
wxPostEvent(this, evt);

fFound = true;
break;
}
}

if (!fFound) {
wxMessageBox(
wxString::Format("Startup variable \"%s\" not found.", m_strStartupVariable),
"Variable not found",
wxOK | wxICON_WARNING
);
}
}

// Dimensions
m_vardimsizer = new wxFlexGridSizer(NcVarMaximumDimensions+1, 4, 0, 0);

Expand Down
5 changes: 5 additions & 0 deletions src/wxNcVisFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,11 @@ class wxNcVisFrame : public wxFrame {
/// </summary>
VariableNameFileIxMap m_mapVarNames[10];

/// <summary>
/// Startup variable name.
/// </summary>
wxString m_strStartupVariable;

private:
/// <summary>
/// ColorMap index.
Expand Down