------------------------------------------------------------------------------
| 286 | |
| 287 | //------------------------------------------------------------------------------ |
| 288 | void vtkLegendScaleActor::UpdateAxisRange(vtkAxisActor2D* axis, vtkViewport* viewport, bool invert) |
| 289 | { |
| 290 | double* minPoint = axis->GetPositionCoordinate()->GetComputedWorldValue(viewport); |
| 291 | double* maxPoint = axis->GetPosition2Coordinate()->GetComputedWorldValue(viewport); |
| 292 | |
| 293 | double range[2]; |
| 294 | if (this->LabelMode == COORDINATES) |
| 295 | { |
| 296 | int mainOrientation = 0; |
| 297 | double size = 0; |
| 298 | for (int comp = 0; comp < 3; comp++) |
| 299 | { |
| 300 | // COORDINATES is expected to be used only if the screen is parallel |
| 301 | // to one of the main planes, i.e. vtkAxisActor2D should be aligned with |
| 302 | // one of the scene axes. So find it. |
| 303 | double componentSize = std::abs(maxPoint[comp] - minPoint[comp]); |
| 304 | if (componentSize > size) |
| 305 | { |
| 306 | mainOrientation = comp; |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | range[0] = minPoint[mainOrientation] - this->Origin[mainOrientation]; |
| 311 | range[1] = maxPoint[mainOrientation] - this->Origin[mainOrientation]; |
| 312 | } |
| 313 | else |
| 314 | { |
| 315 | double d = sqrt(vtkMath::Distance2BetweenPoints(minPoint, maxPoint)); |
| 316 | range[0] = -d / 2; |
| 317 | range[1] = d / 2; |
| 318 | if (invert) |
| 319 | { |
| 320 | range[0] = -range[0]; |
| 321 | range[1] = -range[1]; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | axis->SetRange(range); |
| 326 | } |
| 327 | |
| 328 | //------------------------------------------------------------------------------ |
| 329 | void vtkLegendScaleActor::BuildRepresentation(vtkViewport* viewport) |
no test coverage detected