| 471 | } |
| 472 | |
| 473 | int vtkScalarBarActor::RebuildLayoutIfNeeded(vtkViewport* viewport) |
| 474 | { |
| 475 | if (!this->LookupTable) |
| 476 | { |
| 477 | vtkWarningMacro(<< "Need a lookup table to render a scalar bar"); |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | if (!this->TitleTextProperty) |
| 482 | { |
| 483 | vtkErrorMacro(<< "Need title text property to render a scalar bar"); |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | if (!this->LabelTextProperty) |
| 488 | { |
| 489 | vtkErrorMacro(<< "Need label text property to render a scalar bar"); |
| 490 | return 0; |
| 491 | } |
| 492 | |
| 493 | if (!this->AnnotationTextProperty) |
| 494 | { |
| 495 | vtkErrorMacro(<< "Need annotation text property to render a scalar bar"); |
| 496 | return 0; |
| 497 | } |
| 498 | |
| 499 | // Check to see whether we have to rebuild everything |
| 500 | int positionsHaveChanged = 0; |
| 501 | if (viewport->GetMTime() > this->BuildTime || |
| 502 | (viewport->GetVTKWindow() && viewport->GetVTKWindow()->GetMTime() > this->BuildTime)) |
| 503 | { |
| 504 | // if the viewport has changed we may - or may not need |
| 505 | // to rebuild, it depends on if the projected coords change |
| 506 | int size[2]; |
| 507 | int* barOrigin; |
| 508 | barOrigin = this->PositionCoordinate->GetComputedViewportValue(viewport); |
| 509 | size[0] = this->Position2Coordinate->GetComputedViewportValue(viewport)[0] - barOrigin[0]; |
| 510 | size[1] = this->Position2Coordinate->GetComputedViewportValue(viewport)[1] - barOrigin[1]; |
| 511 | |
| 512 | // Check if we have bounds on the maximum size |
| 513 | size[0] = size[0] > this->MaximumWidthInPixels ? this->MaximumWidthInPixels : size[0]; |
| 514 | size[1] = size[1] > this->MaximumHeightInPixels ? this->MaximumHeightInPixels : size[1]; |
| 515 | |
| 516 | if (this->LastSize[0] != size[0] || this->LastSize[1] != size[1] || |
| 517 | this->LastOrigin[0] != barOrigin[0] || this->LastOrigin[1] != barOrigin[1]) |
| 518 | { |
| 519 | positionsHaveChanged = 1; |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | // Check to see whether we have to rebuild everything |
| 524 | if (positionsHaveChanged || this->GetMTime() > this->BuildTime || |
| 525 | this->LookupTable->GetMTime() > this->BuildTime || |
| 526 | this->AnnotationTextProperty->GetMTime() > this->BuildTime || |
| 527 | this->LabelTextProperty->GetMTime() > this->BuildTime || |
| 528 | this->TitleTextProperty->GetMTime() > this->BuildTime || |
| 529 | this->BackgroundProperty->GetMTime() > this->BuildTime || |
| 530 | this->FrameProperty->GetMTime() > this->BuildTime || |
no test coverage detected