Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashing issues on mac build when running defaults #1479 #1502

Merged
merged 1 commit into from
Oct 18, 2023
Merged
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
34 changes: 13 additions & 21 deletions src/casewin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,15 +1396,11 @@ void CaseWindow::UpdateConfiguration()
wxDataViewItem cont_pv;
wxDataViewItemArray dvia{ m_pageGroups.size() + 1 };
wxArrayString bin_list;
//wxDataViewItemArray dvia;
wxArrayString page_list;
wxString bin_name;
wxString bin_name_prev;
int Ts_count = 0;
int bin_count = 0;
for (int i = 0; i < m_pageGroups.size(); i++) {
if (m_pageGroups[i]->ExclTop) {

if (bin_list.Index("Hybrid") == wxNOT_FOUND) {
dvia[0] = m_navigationMenu->AppendContainer(wxDataViewItem(0), "Hybrid");
}
Expand Down Expand Up @@ -1438,24 +1434,20 @@ void CaseWindow::UpdateConfiguration()
m_navigationMenu->AppendItem(wxDataViewItem(0), m_pageGroups[j]->SideBarLabel);
}
}

if (m_navigationMenu->IsContainer(dvia[0])) {
m_navigationMenu->Expand(dvia[0]);
wxDataViewItemArray dvic;
m_navigationMenu->GetModel()->GetChildren(dvia[0], dvic);
m_navigationMenu->SetCurrentItem(dvic[0]);
SwitchToInputPage(m_navigationMenu->GetItemText(m_navigationMenu->GetCurrentItem()));
}
else if (m_navigationMenu->IsContainer(dvia[1])) {
m_navigationMenu->Expand(dvia[1]);
wxDataViewItemArray dvic;
m_navigationMenu->GetModel()->GetChildren(dvia[1], dvic);
m_navigationMenu->SetCurrentItem(dvic[0]);
SwitchToInputPage(m_navigationMenu->GetItemText(m_navigationMenu->GetCurrentItem()));
}
m_currentSelection = (m_navigationMenu->GetCurrentItem());

// check for orphaned notes and if any found add to first page per Github issue 796

wxDataViewItem dvi = m_navigationMenu->GetNthChild(wxDataViewItem(0), 0);
if (m_navigationMenu->IsContainer(dvi)) {
dvi = m_navigationMenu->GetNthChild(dvi, 0);
}

if (dvi.IsOk()) {
m_navigationMenu->SetCurrentItem(dvi);
SwitchToInputPage(m_navigationMenu->GetItemText(dvi));
m_currentSelection = (dvi);
}

// check for orphaned notes and if any found add to first page per Github issue 796
CheckAndUpdateNotes(inputPageHelpContext);

m_szsims->Clear(true);
Expand Down
166 changes: 30 additions & 136 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2910,27 +2910,6 @@ void ConfigDialog::PopulateTech()
// list all technologies
m_tnames = SamApp::Config().GetTechnologies();

//wxString bin_name;
//wxArrayString tech_list;
//wxDataViewItemArray dvia{m_tnames.Count()};
/*
for (int j = 0; j < m_tnames.Count(); j++) {
wxString L(SamApp::Config().Options(m_tnames[j]).LongName);
wxString TP(SamApp::Config().Options(m_tnames[j]).TreeParent);
if (L.IsEmpty()) L = m_tnames[j];
if (tech_list.Index(TP) == wxNOT_FOUND && TP != "" && TP != "Retired") {
tech_list.Add(TP);
dvia[tech_list.Index(TP)] = m_pTech->AppendContainer(wxDataViewItem(0), TP);
}
if (TP.Find("Retired") != wxNOT_FOUND); //do nothing for Retired technologies
else if (tech_list.Index(TP) != wxNOT_FOUND) {
m_pTech->AppendItem(dvia[tech_list.Index(TP)],L);
}
else {
m_pTech->AppendItem(wxDataViewItem(0), L);
}
}
*/
// tree containers and nodes
wxArrayString containers, nodes, added;
for (int j = 0; j < m_tnames.Count(); j++) {
Expand All @@ -2947,122 +2926,37 @@ void ConfigDialog::PopulateTech()

// order from startup.lk configopt("TechnologyTreeOrder", ...
wxString TreeOrder = SamApp::Config().Options("TechnologyTreeOrder").Description;
/*
if (TreeOrder.length() < 1) { // non-ordered
wxArrayString tech_list;
wxDataViewItemArray dvia{m_tnames.Count()};

for (int j = 0; j < m_tnames.Count(); j++) {
wxString L(SamApp::Config().Options(m_tnames[j]).LongName);
wxString TP(SamApp::Config().Options(m_tnames[j]).TreeParent);
if (L.IsEmpty()) L = m_tnames[j];
if (tech_list.Index(TP) == wxNOT_FOUND && TP != "" && TP != "Retired") {
tech_list.Add(TP);
dvia[tech_list.Index(TP)] = m_pTech->AppendContainer(wxDataViewItem(0), TP);
}
if (TP.Find("Retired") != wxNOT_FOUND); //do nothing for Retired technologies
else if (tech_list.Index(TP) != wxNOT_FOUND) {
m_pTech->AppendItem(dvia[tech_list.Index(TP)],L);
}
else {
m_pTech->AppendItem(wxDataViewItem(0), L);
}
}
}
else*/ { // ordered per Description
wxArrayString order = wxSplit(TreeOrder, ',');
for (auto& item : order) {
if (containers.Index(item) != wxNOT_FOUND)
dvia[containers.Index(item)] = m_pTech->AppendContainer(wxDataViewItem(0), item);
else if (nodes.Index(item) != wxNOT_FOUND)
m_pTech->AppendItem(wxDataViewItem(0), item);
}
// append remaining nodes to appropriate containers
for (auto& item : m_tnames) {
wxString node(SamApp::Config().Options(item).LongName);
wxString container(SamApp::Config().Options(item).TreeParent);
if (node.IsEmpty()) node = item;
// skip those already added
if (order.Index(node) != wxNOT_FOUND) continue;
if (order.Index(container) != wxNOT_FOUND)
m_pTech->AppendItem(dvia[containers.Index(container)], node);
else {
if (added.Index(container) == wxNOT_FOUND && container != "" && container != "Retired") {
added.Add(container);
dvia[containers.Index(container)] = m_pTech->AppendContainer(wxDataViewItem(0), container);
}
if (container.Find("Retired") != wxNOT_FOUND); //do nothing for Retired technologies
else if (containers.Index(container) != wxNOT_FOUND) {
m_pTech->AppendItem(dvia[containers.Index(container)], node);
}
else {
m_pTech->AppendItem(wxDataViewItem(0), node);
}
wxArrayString order = wxSplit(TreeOrder, ',');
for (auto& item : order) {
if (containers.Index(item) != wxNOT_FOUND)
dvia[containers.Index(item)] = m_pTech->AppendContainer(wxDataViewItem(0), item);
else if (nodes.Index(item) != wxNOT_FOUND)
m_pTech->AppendItem(wxDataViewItem(0), item);
}
// append remaining nodes to appropriate containers
for (auto& item : m_tnames) {
wxString node(SamApp::Config().Options(item).LongName);
wxString container(SamApp::Config().Options(item).TreeParent);
if (node.IsEmpty()) node = item;
// skip those already added
if (order.Index(node) != wxNOT_FOUND) continue;
if (order.Index(container) != wxNOT_FOUND)
m_pTech->AppendItem(dvia[containers.Index(container)], node);
else {
if (added.Index(container) == wxNOT_FOUND && container != "" && container != "Retired") {
added.Add(container);
dvia[containers.Index(container)] = m_pTech->AppendContainer(wxDataViewItem(0), container);
}
if (container.Find("Retired") != wxNOT_FOUND); //do nothing for Retired technologies
else if (containers.Index(container) != wxNOT_FOUND) {
m_pTech->AppendItem(dvia[containers.Index(container)], node);
}
else {
m_pTech->AppendItem(wxDataViewItem(0), node);
}

}
}
/*
// TODO - handle those not specified in TreeOrder
wxArrayString tech_list;
// dvia.Clear();
// dvia.resize(m_tnames.Count());
// wxDataViewItemArray dvia{ m_tnames.Count() };

for (int j = 0; j < m_tnames.Count(); j++) {
wxString L(SamApp::Config().Options(m_tnames[j]).LongName);
wxString TP(SamApp::Config().Options(m_tnames[j]).TreeParent);
if (L.IsEmpty()) L = m_tnames[j];
if (order.Index(TP) != wxNOT_FOUND) continue;
if (order.Index(L) != wxNOT_FOUND) continue;
if (tech_list.Index(TP) == wxNOT_FOUND && TP != "" && TP != "Retired") {
tech_list.Add(TP);
dvia[tech_list.Index(TP)] = m_pTech->AppendContainer(wxDataViewItem(0), TP);
}
if (TP.Find("Retired") != wxNOT_FOUND); //do nothing for Retired technologies
else if (tech_list.Index(TP) != wxNOT_FOUND) {
m_pTech->AppendItem(dvia[tech_list.Index(TP)], L);
}
else {
m_pTech->AppendItem(wxDataViewItem(0), L);
}

}
*/
}



// Manually add groups here - eventually move to startup.lk
//wxDataViewItem cont_pv = m_pTech->AppendContainer(wxDataViewItem(0), "Photovoltaic");
//wxDataViewItem cont_batt = m_pTech->AppendContainer(wxDataViewItem(0), "Energy Storage");
//wxDataViewItem cont_csp = m_pTech->AppendContainer(wxDataViewItem(0), "Concentrating Solar Power");
//wxDataViewItem cont_heat = m_pTech->AppendContainer(wxDataViewItem(0), "Heat");
//wxDataViewItem cont_me = m_pTech->AppendContainer(wxDataViewItem(0), "Marine Energy");
//wxDataViewItem cont_hybrid = m_pTech->AppendContainer(wxDataViewItem(0), "Hybrid Power");

//for( size_t i=0;i<m_tnames.Count();i++)
//{
// wxString L(SamApp::Config().Options(m_tnames[i]).LongName);
// wxString TP(SamApp::Config().Options(m_tnames[i]).TreeParent);
// if ( L.IsEmpty() ) L = m_tnames[i];
// if (TP.Find("PV") != wxNOT_FOUND)
// m_pTech->AppendItem(cont_pv, L);
// else if (TP.Find("Heat") != wxNOT_FOUND)
// m_pTech->AppendItem(cont_heat, L);
// else if (TP.Find("CSP") != wxNOT_FOUND )
// m_pTech->AppendItem(cont_csp, L);
// else if (TP.Find("Retired") != wxNOT_FOUND); //Remove dish stirling, direct steam power tower from the list of selectable technologies
// else if (TP.Find("ME") != wxNOT_FOUND)
// m_pTech->AppendItem(cont_me, L);
// else if (TP.Find("BATT") != wxNOT_FOUND)
// m_pTech->AppendItem(cont_batt, L);
// else if (TP.Find("Hybrid") != wxNOT_FOUND)
// m_pTech->AppendItem(cont_hybrid, L);
// else
// m_pTech->AppendItem(wxDataViewItem(0), L);

//
//}
}
}

}

Expand Down
8 changes: 7 additions & 1 deletion src/results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,13 @@ void ResultsViewer::Setup(Simulation* sim)
}
if (tech_model == "Flat Plate PV" || tech_model == "PV Battery")
{
m_spatialLayout->DeleteAll();
// if model was changed from another technology, the ResultsViewer was not initialized with Uncertainties
if (!m_spatialLayout) {
m_spatialLayout = new wxSnapLayout(this, wxID_ANY);
AddPage(m_spatialLayout, "Spatial", true);
}
else
m_spatialLayout->DeleteAll();

wxString x_label;
if (m_sim->GetValue("subarray1_track_mode")->Value() == 1) { // 0=fixed, 1=1-axis, 2=2-axis, 3=azimuth-axis, 4=seasonal
Expand Down