MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / OnCommand

Method OnCommand

src/widgets.cpp:1835–1950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1833 }
1834
1835 void OnCommand(wxCommandEvent &evt)
1836 {
1837 if (evt.GetId() == IDDD_CHANGENUMROWS)
1838 {
1839 long l=0;
1840 if (mMode == DATA_ARRAY_8760_MULTIPLES)
1841 {
1842 int nmult = mData.size()/8760;
1843 double tmstp = nmult != 0 ? 1.0/((double)nmult) : 1.0;
1844
1845 wxString result = wxGetTextFromUser("Enter time step (minutes):", "Edit Table",
1846 wxString::Format("%lg", tmstp*60), this );
1847
1848 if (result.IsEmpty())
1849 return;
1850
1851 tmstp = wxAtof(result)/60.0;
1852 if (tmstp > 0 && (int)(1.0/tmstp) > 0)
1853 {
1854 l = 8760*(int)(1.0/tmstp);
1855 }
1856 else
1857 {
1858 wxMessageBox("Invalid time step.");
1859 return;
1860 }
1861 }
1862 else
1863 {
1864 wxString result = wxGetTextFromUser("Enter number of data rows", "Edit Table",
1865 wxString::Format("%d", Grid->GetNumberRows()), this );
1866 if (result.IsEmpty()) return;
1867
1868 if (!result.ToLong(&l))
1869 return;
1870 }
1871
1872 if ( l > 0 )
1873 {
1874 if (mMode == DATA_ARRAY_8760_ONLY)
1875 {
1876 l = 8760;
1877 }
1878 else if (mMode == DATA_ARRAY_8760_MULTIPLES)
1879 {
1880 int nmult = l/8760;
1881 l=nmult*8760;
1882 if (l < 8760) l = 8760;
1883 }
1884
1885 Grid->ResizeGrid( l, 1 );
1886 }
1887 else
1888 wxMessageBox("Invalid number of rows or non-numeric entry.");
1889 }
1890 else if (evt.GetId() == IDDD_COPY)
1891 Grid->Copy(true);
1892 else if (evt.GetId() == IDDD_PASTE)

Callers

nothing calls this directly

Calls 7

SetDataFunction · 0.85
GetIdMethod · 0.80
sizeMethod · 0.80
ResizeGridMethod · 0.80
GetNumberRowsMethod · 0.45
CopyMethod · 0.45
ShowModalMethod · 0.45

Tested by

no test coverage detected