------------------------------------------------------------------------------
| 110 | |
| 111 | //------------------------------------------------------------------------------ |
| 112 | void vtkLeaderActor2D::BuildLeader(vtkViewport* viewport) |
| 113 | { |
| 114 | // Check to see whether we need to rebuild----------------------------- |
| 115 | int positionsHaveChanged = 0; |
| 116 | if (viewport->GetMTime() > this->BuildTime || |
| 117 | (viewport->GetVTKWindow() && viewport->GetVTKWindow()->GetMTime() > this->BuildTime)) |
| 118 | { |
| 119 | int* lastPosition = this->PositionCoordinate->GetComputedViewportValue(viewport); |
| 120 | int* lastPosition2 = this->Position2Coordinate->GetComputedViewportValue(viewport); |
| 121 | if (lastPosition[0] != this->LastPosition[0] || lastPosition[1] != this->LastPosition[1] || |
| 122 | lastPosition2[0] != this->LastPosition2[0] || lastPosition2[1] != this->LastPosition2[1]) |
| 123 | { |
| 124 | positionsHaveChanged = 1; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | const int* size = viewport->GetSize(); |
| 129 | int viewportSizeHasChanged = 0; |
| 130 | // See whether fonts have to be rebuilt (font size depends on viewport size) |
| 131 | if (this->LastSize[0] != size[0] || this->LastSize[1] != size[1]) |
| 132 | { |
| 133 | viewportSizeHasChanged = 1; |
| 134 | this->LastSize[0] = size[0]; |
| 135 | this->LastSize[1] = size[1]; |
| 136 | } |
| 137 | |
| 138 | if (!positionsHaveChanged && !viewportSizeHasChanged && this->GetMTime() < this->BuildTime && |
| 139 | this->LabelTextProperty->GetMTime() < this->BuildTime) |
| 140 | { |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | // Okay, we have some work to do. We build the leader in three parts: |
| 145 | // 1) the line connecting the two points, 2) the text label, and 3) the |
| 146 | // arrow head(s) if any. |
| 147 | vtkDebugMacro(<< "Rebuilding leader"); //--------------------------------- |
| 148 | |
| 149 | // Initialize the data |
| 150 | this->LeaderPoints->Initialize(); |
| 151 | this->LeaderLines->Initialize(); |
| 152 | this->LeaderArrows->Initialize(); |
| 153 | this->LeaderActor->SetProperty(this->GetProperty()); |
| 154 | this->LabelMapper->SetTextProperty(this->LabelTextProperty); |
| 155 | |
| 156 | // The easiest part is determining the two end points of the line. |
| 157 | double p1[3], p2[3], ray[3]; |
| 158 | int* x = this->PositionCoordinate->GetComputedViewportValue(viewport); |
| 159 | p1[0] = static_cast<double>(x[0]); |
| 160 | p1[1] = static_cast<double>(x[1]); |
| 161 | p1[2] = 0.0; |
| 162 | this->LastPosition[0] = x[0]; |
| 163 | this->LastPosition[1] = x[1]; |
| 164 | |
| 165 | x = this->Position2Coordinate->GetComputedViewportValue(viewport); |
| 166 | p2[0] = static_cast<double>(x[0]); |
| 167 | p2[1] = static_cast<double>(x[1]); |
| 168 | p2[2] = 0.0; |
| 169 | this->LastPosition2[0] = x[0]; |
no test coverage detected