| 298 | } |
| 299 | |
| 300 | void ColocationSelectDlg::OnVarSelect( wxCommandEvent& event) |
| 301 | { |
| 302 | co_val_dict.clear(); |
| 303 | var_selections.Clear(); |
| 304 | select_vars.clear(); |
| 305 | |
| 306 | clear_colo_control(); |
| 307 | |
| 308 | std::vector<int> tms; |
| 309 | |
| 310 | combo_var->GetSelections(var_selections); |
| 311 | size_t num_var = var_selections.size(); |
| 312 | if (num_var >= 2) { |
| 313 | // check selected variables for any co-located values, and add them to choice box |
| 314 | col_ids.resize(num_var); |
| 315 | std::vector<wxString> col_names; |
| 316 | col_names.resize(num_var); |
| 317 | for (int i=0; i<num_var; i++) { |
| 318 | int idx = var_selections[i]; |
| 319 | wxString sel_str = combo_var->GetString(idx); |
| 320 | select_vars.push_back(sel_str); |
| 321 | |
| 322 | wxString nm = name_to_nm[sel_str]; |
| 323 | col_names.push_back(nm); |
| 324 | |
| 325 | int tm = name_to_tm_id[combo_var->GetString(idx)]; |
| 326 | tms.push_back(tm); |
| 327 | |
| 328 | int col = table_int->FindColId(nm); |
| 329 | if (col == wxNOT_FOUND) { |
| 330 | wxString err_msg = wxString::Format(_("Variable %s is no longer in the Table. Please close and reopen this dialog to synchronize with Table data."), nm); |
| 331 | wxMessageDialog dlg(NULL, err_msg, _("Error"), wxOK | wxICON_ERROR); |
| 332 | dlg.ShowModal(); |
| 333 | return; |
| 334 | } |
| 335 | col_ids[i] = col; |
| 336 | } |
| 337 | rows = project->GetNumRecords(); |
| 338 | columns = 0; |
| 339 | |
| 340 | std::vector<l_array_type> data; |
| 341 | std::vector<b_array_type> data_undef; |
| 342 | data.resize(col_ids.size()); // data[variable][time][obs] |
| 343 | data_undef.resize(col_ids.size()); // data_undef[variable][time][obs] |
| 344 | for (int i=0; i<col_ids.size(); i++) { |
| 345 | table_int->GetColData(col_ids[i], data[i]); |
| 346 | table_int->GetColUndefined(col_ids[i], data_undef[i]); |
| 347 | } |
| 348 | |
| 349 | std::vector<std::set<wxInt64> > same_val_counts(rows); |
| 350 | std::vector<bool> same_undef(rows, false); |
| 351 | for (int i=0; i<data.size(); i++ ){ // col |
| 352 | int j = tms[i]; |
| 353 | //for (int j=0; j<data[i].size(); j++) // time |
| 354 | { |
| 355 | columns += 1; |
| 356 | for (int k=0; k< rows;k++) { // row |
| 357 | same_undef[k] = same_undef[k] || data_undef[i][j][k]; |
nothing calls this directly
no test coverage detected