Skip to content

Commit

Permalink
Merge pull request #1498 from NREL/SAM_1455
Browse files Browse the repository at this point in the history
addresses SAM issue 1455
  • Loading branch information
sjanzou authored Oct 17, 2023
2 parents 8bfe926 + eac7c31 commit ed0b465
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 122 deletions.
4 changes: 4 additions & 0 deletions deploy/runtime/startup.lk
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ addconfig('PVWatts Wind FuelCell Battery Hybrid', ['Single Owner', 'Host Develop
addconfig('Photovoltaic Wind Battery Hybrid', ['Single Owner', 'Host Developer']);
addconfig('Generic PVWatts Wind FuelCell Battery Hybrid', ['Single Owner', 'Host Developer']);


// order tech and fin trees
configopt("TechnologyTreeOrder", {'description' = 'Hybrid,Wind,Generic System,Photovoltaic,Geothermal'});

// group names 'tree_parent' for performance models are defined in PopulateTech() in main.cpp
configopt( 'Flat Plate PV', { 'tree_parent'='Photovoltaic', 'long_name'='Detailed PV Model', 'short_name'='Photovoltaic', 'description'='Photovoltaic system using detailed photovoltaic model with separate module and inverter component models' } );
configopt( 'PVWatts', { 'tree_parent'='Photovoltaic','long_name'='PVWatts', 'short_name'='PVWatts', 'description'='Photovoltaic system using basic NREL PVWatts V8 algorithm. Does not do detailed degradation or loss modeling. If those are important, please use pvsamv1.' } );
Expand Down
118 changes: 45 additions & 73 deletions src/casewin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ BEGIN_EVENT_TABLE( CaseWindow, wxSplitterWindow )
EVT_MENU(ID_PVUNCERTAINTY, CaseWindow::OnCommand)
EVT_MENU( ID_MACRO, CaseWindow::OnCommand )
EVT_LISTBOX( ID_INPUTPAGELIST, CaseWindow::OnCommand )
EVT_DATAVIEW_SELECTION_CHANGED(ID_TechTree, CaseWindow::OnTechTree)
EVT_DATAVIEW_ITEM_START_EDITING(ID_TechTree, CaseWindow::OnTreeActivated)
EVT_DATAVIEW_ITEM_ACTIVATED(ID_TechTree, CaseWindow::OnTreeActivated)
EVT_DATAVIEW_SELECTION_CHANGED(ID_TechTree, CaseWindow::OnTree)
EVT_DATAVIEW_ITEM_COLLAPSING(ID_TechTree, CaseWindow::OnTreeCollapsing)

// EVT_DATAVIEW_ITEM_START_EDITING(ID_TechTree, CaseWindow::OnTreeActivated)
// EVT_DATAVIEW_ITEM_ACTIVATED(ID_TechTree, CaseWindow::OnTreeActivated)
//EVT_LISTBOX( ID_TechTree, CaseWindow::OnCommand)
EVT_BUTTON( ID_EXCL_BUTTON, CaseWindow::OnCommand )
EVT_LISTBOX( ID_EXCL_RADIO, CaseWindow::OnCommand)
Expand Down Expand Up @@ -377,7 +379,7 @@ bool CaseWindow::RunBaseCase( bool silent, wxString *messages )
m_inputPageList->Select( -1 );
//m_navigationMenu->SetCurrentItem(wxDataViewItem(0));

wxDataViewItemArray dvia;
// wxDataViewItemArray dvia;
m_navigationMenu->UnselectAll();
/*
m_navigationMenu->GetModel()->GetChildren(wxDataViewItem(0), dvia);
Expand Down Expand Up @@ -626,79 +628,48 @@ bool CaseWindow::GenerateReport( wxString pdffile, wxString templfile, VarValue
return false;
}

void CaseWindow::OnTechTree(wxDataViewEvent&)
void CaseWindow::OnTree(wxDataViewEvent &evt)
{
m_pageFlipper->SetSelection(0);
if (m_navigationMenu->IsContainer(m_navigationMenu->GetCurrentItem()))
{
wxDataViewItemArray dvic;
bool keep_open = false;
wxDataViewItem current_item;
wxString test = m_navigationMenu->GetItemText(m_navigationMenu->GetCurrentItem());
wxString test_previous = m_navigationMenu->GetItemText(m_previousPage);
current_item = m_navigationMenu->GetCurrentItem();
if (test == "") { //click arrow instead of word
keep_open = true;
current_item = m_previousPage;
//m_navigationMenu->UnselectAll();
wxString string = m_navigationMenu->GetItemText(current_item);
m_navigationMenu->SetCurrentItem(current_item);
wxDataViewItem parent = m_navigationMenu->GetModel()->GetParent(m_navigationMenu->GetCurrentItem());
wxString string2 = m_navigationMenu->GetItemText(parent);
// m_navigationMenu->UnselectAll();
// m_navigationMenu->SetCurrentItem(parent);
SwitchToInputPage(string2 + " Summary");
//m_navigationMenu->Expand(m_navigationMenu->GetModel()->GetParent(m_navigationMenu->GetCurrentItem()));
m_navigationMenu->Update();
return;
}
m_navigationMenu->GetModel()->GetChildren(m_navigationMenu->GetCurrentItem(), dvic);
int children_count = dvic.Count();
for (int i = 0; i < dvic.Count(); i++) {
if (dvic[i] == m_previousPage) {
keep_open = true;
current_item = dvic[i];
m_navigationMenu->SetCurrentItem(dvic[i]);
//m_navigationMenu->Update();
return;
}
}
if (!keep_open && m_navigationMenu->IsExpanded(m_navigationMenu->GetCurrentItem())) {
m_navigationMenu->Collapse(m_navigationMenu->GetCurrentItem());
m_navigationMenu->SetCurrentItem(m_previousPage);
m_navigationMenu->Update();
return;
}
m_navigationMenu->Expand(m_navigationMenu->GetCurrentItem());
m_navigationMenu->SetCurrentItem(m_previousPage);
//m_navigationMenu->Update();
//wxDataViewItemArray dvia;
m_pageFlipper->SetSelection(0);
wxDataViewItem dvi = evt.GetItem();
if (!dvi.IsOk())
return;

if (m_navigationMenu->IsContainer(dvi))
{
if (m_navigationMenu->IsExpanded(dvi))
m_navigationMenu->Collapse(dvi);
else
m_navigationMenu->Expand(dvi);
if (m_currentSelection.IsOk()) {// keep current selection
m_navigationMenu->SetCurrentItem(m_currentSelection);
return;
}
else {// select first child
m_currentSelection = m_navigationMenu->GetNthChild(dvi, 0);
m_navigationMenu->SetCurrentItem(m_currentSelection);
}
}
else {
m_currentSelection = evt.GetItem();
}
wxString title = m_navigationMenu->GetItemText(m_currentSelection);
SwitchToInputPage(title);

/*
m_navigationMenu->GetModel()->GetChildren(m_navigationMenu->GetCurrentItem(), dvia);
if (m_navigationMenu->GetItemText(dvia[0]) != L"")
SwitchToInputPage(m_navigationMenu->GetItemText(dvia[0]));
*/

}
else {
wxDataViewItemArray dvia;
wxDataViewItem parent = m_navigationMenu->GetModel()->GetParent(m_navigationMenu->GetCurrentItem());
m_navigationMenu->GetModel()->GetChildren(parent, dvia);
if (dvia.Count() > 0) {
SwitchToInputPage(m_navigationMenu->GetItemText(m_navigationMenu->GetCurrentItem()));
m_previousPage = (m_navigationMenu->GetCurrentItem());
}
m_navigationMenu->Update();

}
//m_navigationMenu->Update();

}

void CaseWindow::OnTreeActivated(wxDataViewEvent& evt)
void CaseWindow::OnTreeCollapsing(wxDataViewEvent& evt)
{
evt.Veto();
wxDataViewItem dvi = evt.GetItem();
if (dvi.IsOk() && m_navigationMenu->IsContainer(dvi)) {
auto selectedDVI = m_navigationMenu->GetCurrentItem();
if (selectedDVI.IsOk()) {
for (size_t i = 0; i < m_navigationMenu->GetChildCount(dvi); i++) {
if (selectedDVI == m_navigationMenu->GetNthChild(dvi, i))
evt.Veto();
}
}
}
}

void CaseWindow::OnCommand( wxCommandEvent &evt )
Expand All @@ -712,6 +683,7 @@ void CaseWindow::OnCommand( wxCommandEvent &evt )
{
m_inputPageList->Select( -1 );
m_pageFlipper->SetSelection( 1 );
m_navigationMenu->UnselectAll();
}
else if ( evt.GetId() == ID_ADVANCED )
{
Expand Down Expand Up @@ -1481,7 +1453,7 @@ void CaseWindow::UpdateConfiguration()
m_navigationMenu->SetCurrentItem(dvic[0]);
SwitchToInputPage(m_navigationMenu->GetItemText(m_navigationMenu->GetCurrentItem()));
}
m_previousPage = (m_navigationMenu->GetCurrentItem());
m_currentSelection = (m_navigationMenu->GetCurrentItem());

// check for orphaned notes and if any found add to first page per Github issue 796
CheckAndUpdateNotes(inputPageHelpContext);
Expand Down
6 changes: 3 additions & 3 deletions src/casewin.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class CaseWindow : public wxSplitterWindow, CaseEventListener
wxStaticText* m_finLabel;
wxMetroButton *m_simButton, *m_resultsButton;
wxMetroDataViewTreeCtrl *m_navigationMenu;
wxDataViewItem m_previousPage;
wxDataViewItem m_currentSelection;

// to allow switching case configurations with P50/P90 and PVUncertainty
wxGridSizer *m_szsims;
Expand All @@ -169,8 +169,8 @@ class CaseWindow : public wxSplitterWindow, CaseEventListener
wxString m_lastPageNoteId;

void OnCommand( wxCommandEvent & );
void OnTechTree(wxDataViewEvent&);
void OnTreeActivated(wxDataViewEvent &evt );
void OnTree(wxDataViewEvent&);
void OnTreeCollapsing(wxDataViewEvent &evt );
virtual void OnCaseEvent( Case *, CaseEvent & );
void OnSubNotebookPageChanged( wxNotebookEvent &evt );

Expand Down
Loading

0 comments on commit ed0b465

Please sign in to comment.