------------------------------------------------------------------------------
| 272 | } |
| 273 | //------------------------------------------------------------------------------ |
| 274 | bool vtkPlotBox::UpdateCache() |
| 275 | { |
| 276 | if (!this->Superclass::UpdateCache()) |
| 277 | { |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | // Each boxplot is a column in our storage array, |
| 282 | // they are scaled from 0.0 to 1.0 |
| 283 | vtkChartBox* parent = vtkChartBox::SafeDownCast(this->Parent); |
| 284 | vtkTable* table = this->Data->GetInput(); |
| 285 | if (!parent || !table || table->GetNumberOfColumns() == 0) |
| 286 | { |
| 287 | return false; |
| 288 | } |
| 289 | |
| 290 | vtkStringArray* cols = parent->GetVisibleColumns(); |
| 291 | |
| 292 | this->Storage->resize(cols->GetNumberOfTuples()); |
| 293 | vtkIdType rows = table->GetNumberOfRows(); |
| 294 | |
| 295 | for (vtkIdType i = 0; i < cols->GetNumberOfTuples(); ++i) |
| 296 | { |
| 297 | std::vector<double>& col = this->Storage->at(i); |
| 298 | col.resize(rows); |
| 299 | vtkSmartPointer<vtkDataArray> data = |
| 300 | vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(cols->GetValue(i).c_str())); |
| 301 | if (!data) |
| 302 | { |
| 303 | continue; |
| 304 | } |
| 305 | |
| 306 | vtkAxis* axis = parent->GetYAxis(); |
| 307 | // Also need the range from the appropriate axis, to normalize points |
| 308 | double min = axis->GetUnscaledMinimum(); |
| 309 | double max = axis->GetUnscaledMaximum(); |
| 310 | double scale = 1.0f / (max - min); |
| 311 | |
| 312 | for (vtkIdType j = 0; j < rows; ++j) |
| 313 | { |
| 314 | col[j] = (data->GetTuple1(j) - min) * scale; |
| 315 | } |
| 316 | std::sort(col.begin(), col.end()); |
| 317 | } |
| 318 | |
| 319 | this->BuildTime.Modified(); |
| 320 | return true; |
| 321 | } |
| 322 | |
| 323 | //------------------------------------------------------------------------------ |
| 324 | void vtkPlotBox::SetLookupTable(vtkScalarsToColors* lut) |
nothing calls this directly
no test coverage detected