------------------------------------------------------------------------------
| 286 | |
| 287 | //------------------------------------------------------------------------------ |
| 288 | bool vtkPlotParallelCoordinates::UpdateCache() |
| 289 | { |
| 290 | if (!this->Superclass::UpdateCache()) |
| 291 | { |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | // Each axis is a column in our storage array, they are scaled from 0.0 to 1.0 |
| 296 | vtkChartParallelCoordinates* parent = vtkChartParallelCoordinates::SafeDownCast(this->Parent); |
| 297 | vtkTable* table = this->Data->GetInput(); |
| 298 | if (!parent || !table || table->GetNumberOfColumns() == 0) |
| 299 | { |
| 300 | return false; |
| 301 | } |
| 302 | |
| 303 | vtkStringArray* cols = parent->GetVisibleColumns(); |
| 304 | |
| 305 | this->Storage->resize(cols->GetNumberOfTuples()); |
| 306 | this->Storage->AxisPos.resize(cols->GetNumberOfTuples()); |
| 307 | vtkIdType rows = table->GetNumberOfRows(); |
| 308 | |
| 309 | for (vtkIdType i = 0; i < cols->GetNumberOfTuples(); ++i) |
| 310 | { |
| 311 | std::vector<float>& col = this->Storage->at(i); |
| 312 | vtkAxis* axis = parent->GetAxis(i); |
| 313 | col.resize(rows); |
| 314 | vtkSmartPointer<vtkDataArray> data = |
| 315 | vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(cols->GetValue(i).c_str())); |
| 316 | if (!data) |
| 317 | { |
| 318 | if (table->GetColumnByName(cols->GetValue(i).c_str())->IsA("vtkStringArray")) |
| 319 | { |
| 320 | // We have a different kind of column - attempt to make it into an enum |
| 321 | vtkStringToCategory* stoc = vtkStringToCategory::New(); |
| 322 | stoc->SetInputData(table); |
| 323 | stoc->SetInputArrayToProcess( |
| 324 | 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_ROWS, cols->GetValue(i).c_str()); |
| 325 | stoc->SetCategoryArrayName("enumPC"); |
| 326 | stoc->Update(); |
| 327 | vtkTable* table2 = vtkTable::SafeDownCast(stoc->GetOutput()); |
| 328 | vtkTable* stringTable = vtkTable::SafeDownCast(stoc->GetOutput(1)); |
| 329 | if (table2) |
| 330 | { |
| 331 | data = vtkArrayDownCast<vtkDataArray>(table2->GetColumnByName("enumPC")); |
| 332 | } |
| 333 | if (stringTable && stringTable->GetColumnByName("Strings")) |
| 334 | { |
| 335 | vtkStringArray* strings = |
| 336 | vtkArrayDownCast<vtkStringArray>(stringTable->GetColumnByName("Strings")); |
| 337 | vtkSmartPointer<vtkDoubleArray> arr = vtkSmartPointer<vtkDoubleArray>::New(); |
| 338 | for (vtkIdType j = 0; j < strings->GetNumberOfTuples(); ++j) |
| 339 | { |
| 340 | arr->InsertNextValue(j); |
| 341 | } |
| 342 | // Now we need to set the range on the string axis |
| 343 | axis->SetCustomTickPositions(arr, strings); |
| 344 | if (strings->GetNumberOfTuples() > 1) |
| 345 | { |
nothing calls this directly
no test coverage detected