| 291 | } |
| 292 | |
| 293 | void LineChartFrame::InitVariableChoiceCtrl() |
| 294 | { |
| 295 | wxLogMessage("LineChartFrame::InitVariableChoiceCtrl()"); |
| 296 | TableInterface* table_int = project->GetTableInt(); |
| 297 | if (table_int == NULL) { |
| 298 | wxLogMessage("ERROR: Table interface NULL."); |
| 299 | return; |
| 300 | } |
| 301 | variable_names.clear(); |
| 302 | std::vector<int> col_id_map; |
| 303 | project->GetTableInt()->FillNumericColIdMap(col_id_map); |
| 304 | for (size_t i=0; i<col_id_map.size(); i++) { |
| 305 | int id = col_id_map[i]; |
| 306 | wxString col_name = project->GetTableInt()->GetColName(id); |
| 307 | variable_names.push_back(col_name); |
| 308 | } |
| 309 | |
| 310 | int n_times = table_int->GetTimeSteps(); |
| 311 | wxString time_range_str(""); |
| 312 | if (n_times == 1) { |
| 313 | time_range_str = wxString::Format("(%s)", table_int->GetTimeString(0)); |
| 314 | } else { |
| 315 | time_range_str = wxString::Format("(%s-%s)", |
| 316 | table_int->GetTimeString(0), |
| 317 | table_int->GetTimeString(n_times-1)); |
| 318 | } |
| 319 | wxString old_sel = choice_variable->GetStringSelection(); |
| 320 | choice_variable->Clear(); |
| 321 | int sel_idx = 0; |
| 322 | for (size_t i=0, sz=variable_names.size(); i<sz; ++i) { |
| 323 | wxString col_name = variable_names[i]; |
| 324 | int col = table_int->FindColId(col_name); |
| 325 | if (table_int->IsColTimeVariant(col)) { |
| 326 | col_name = col_name + " " + time_range_str; |
| 327 | } |
| 328 | choice_variable->Append(col_name); |
| 329 | if (!old_sel.IsEmpty() && old_sel == col_name) { |
| 330 | sel_idx = i; |
| 331 | } |
| 332 | } |
| 333 | choice_variable->Connect(wxEVT_CHOICE, |
| 334 | wxCommandEventHandler(LineChartFrame::OnVariableChoice), |
| 335 | NULL, this); |
| 336 | choice_variable->SetSelection(sel_idx); |
| 337 | } |
| 338 | |
| 339 | void LineChartFrame::InitGroupsChoiceCtrl() |
| 340 | { |
nothing calls this directly
no test coverage detected